version bumps
This commit is contained in:
parent
603915d379
commit
e8afb551ee
14 changed files with 143 additions and 79 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
plugins {
|
plugins {
|
||||||
id "com.android.application"
|
id "com.android.application"
|
||||||
id "kotlin-android"
|
id "kotlin-android"
|
||||||
id "kotlin-kapt"
|
// id "kotlin-kapt"
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
apply from: 'signing.config.gradle'
|
apply from: 'signing.config.gradle'
|
||||||
|
|
@ -14,12 +14,12 @@ try {
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 31
|
compileSdk 35
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "org.fnives.tiktokdownloader"
|
applicationId "org.fnives.tiktokdownloader"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 33
|
targetSdkVersion 35
|
||||||
versionCode 2
|
versionCode 2
|
||||||
versionName "1.3.1"
|
versionName "1.3.1"
|
||||||
|
|
||||||
|
|
@ -43,21 +43,18 @@ android {
|
||||||
}
|
}
|
||||||
release {
|
release {
|
||||||
signingConfig signingConfigs.release
|
signingConfig signingConfigs.release
|
||||||
debuggable true
|
|
||||||
shrinkResources true
|
shrinkResources true
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
|
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
buildFeatures.buildConfig = true
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_17
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_17
|
||||||
}
|
}
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "1.8"
|
jvmTarget = "17"
|
||||||
}
|
|
||||||
lintOptions {
|
|
||||||
abortOnError true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
testOptions.unitTests {
|
testOptions.unitTests {
|
||||||
|
|
@ -71,53 +68,57 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
namespace 'org.fnives.tiktokdownloader'
|
||||||
|
lint {
|
||||||
tasks.configureEach { task ->
|
abortOnError true
|
||||||
if (task.taskIdentity.type.toString() == "class org.jetbrains.kotlin.gradle.tasks.KotlinCompile") {
|
|
||||||
task.kotlinOptions {
|
|
||||||
freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//tasks.configureEach { task ->
|
||||||
|
// if (task.taskIdentity.type.toString() == "class org.jetbrains.kotlin.gradle.tasks.KotlinCompile") {
|
||||||
|
// task.kotlinOptions {
|
||||||
|
// freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
implementation "androidx.core:core-ktx:1.7.0"
|
implementation "androidx.core:core-ktx:1.16.0"
|
||||||
implementation "androidx.appcompat:appcompat:1.4.1"
|
implementation "androidx.appcompat:appcompat:1.7.0"
|
||||||
implementation "androidx.activity:activity-ktx:1.4.0"
|
implementation "androidx.activity:activity-ktx:1.10.1"
|
||||||
implementation "androidx.fragment:fragment-ktx:1.4.1"
|
implementation "androidx.fragment:fragment-ktx:1.8.6"
|
||||||
implementation "com.google.android.material:material:1.5.0"
|
implementation "com.google.android.material:material:1.12.0"
|
||||||
implementation "androidx.constraintlayout:constraintlayout:2.1.3"
|
implementation "androidx.constraintlayout:constraintlayout:2.2.1"
|
||||||
|
|
||||||
// Coroutines
|
// Coroutines
|
||||||
def coroutine_version = "1.6.0"
|
def coroutine_version = "1.7.3"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutine_version"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutine_version"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutine_version"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutine_version"
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version"
|
||||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1"
|
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.9.0"
|
||||||
implementation "androidx.fragment:fragment-ktx:1.4.1"
|
implementation "androidx.fragment:fragment-ktx:1.8.6"
|
||||||
|
|
||||||
def glide_version = "4.11.0"
|
def glide_version = "4.15.1"
|
||||||
implementation "com.github.bumptech.glide:glide:$glide_version"
|
implementation "com.github.bumptech.glide:glide:$glide_version"
|
||||||
kapt "com.github.bumptech.glide:compiler:$glide_version"
|
// kapt "com.github.bumptech.glide:compiler:$glide_version"
|
||||||
|
|
||||||
def okhttp_version = "4.9.3"
|
def okhttp_version = "4.12.0"
|
||||||
implementation "com.squareup.retrofit2:retrofit:2.9.0"
|
implementation "com.squareup.retrofit2:retrofit:2.9.0"
|
||||||
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"
|
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"
|
||||||
implementation 'com.pierfrancescosoffritti.androidyoutubeplayer:core:11.0.1'
|
implementation 'com.pierfrancescosoffritti.androidyoutubeplayer:core:11.0.1'
|
||||||
|
|
||||||
def junit_version = "5.7.0"
|
def junit_version = "5.8.2"
|
||||||
testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version"
|
testImplementation "org.junit.jupiter:junit-jupiter-engine:$junit_version"
|
||||||
testImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version"
|
testImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version"
|
||||||
testImplementation 'com.jraska.livedata:testing-ktx:1.2.0'
|
testImplementation 'com.jraska.livedata:testing-ktx:1.2.0'
|
||||||
testImplementation "org.mockito.kotlin:mockito-kotlin:4.0.0"
|
testImplementation "org.mockito.kotlin:mockito-kotlin:4.0.0"
|
||||||
testImplementation "com.squareup.okhttp3:mockwebserver:$okhttp_version"
|
testImplementation "com.squareup.okhttp3:mockwebserver:$okhttp_version"
|
||||||
testImplementation "commons-io:commons-io:2.8.0"
|
testImplementation "commons-io:commons-io:2.13.0"
|
||||||
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutine_version"
|
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutine_version"
|
||||||
testImplementation "androidx.arch.core:core-testing:2.1.0"
|
testImplementation "androidx.arch.core:core-testing:2.2.0"
|
||||||
|
|
||||||
androidTestImplementation "androidx.test.ext:junit:1.1.3"
|
androidTestImplementation "androidx.test.ext:junit:1.2.1"
|
||||||
androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"
|
androidTestImplementation "androidx.test.espresso:espresso-core:3.6.1"
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
package="org.fnives.tiktokdownloader">
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission
|
<uses-permission
|
||||||
|
|
@ -9,10 +8,12 @@
|
||||||
android:maxSdkVersion="28"
|
android:maxSdkVersion="28"
|
||||||
tools:ignore="ScopedStorage" />
|
tools:ignore="ScopedStorage" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".App"
|
android:name=".App"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||||
android:fullBackupContent="false"
|
android:fullBackupContent="false"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
|
@ -40,7 +41,9 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<service android:name=".ui.service.QueueService" />
|
<service
|
||||||
|
android:name=".ui.service.QueueService"
|
||||||
|
android:foregroundServiceType="dataSync" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
package org.fnives.tiktokdownloader.di
|
package org.fnives.tiktokdownloader.di
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.savedstate.SavedStateRegistryOwner
|
|
||||||
import org.fnives.tiktokdownloader.di.module.AndroidFileManagementModule
|
import org.fnives.tiktokdownloader.di.module.AndroidFileManagementModule
|
||||||
import org.fnives.tiktokdownloader.di.module.LocalSourceModule
|
import org.fnives.tiktokdownloader.di.module.LocalSourceModule
|
||||||
import org.fnives.tiktokdownloader.di.module.NetworkModule
|
import org.fnives.tiktokdownloader.di.module.NetworkModule
|
||||||
|
|
@ -29,18 +27,16 @@ object ServiceLocator {
|
||||||
val useCaseModule: UseCaseModule
|
val useCaseModule: UseCaseModule
|
||||||
get() = _useCaseModule ?: throw IllegalStateException("$this.start has not been called!")
|
get() = _useCaseModule ?: throw IllegalStateException("$this.start has not been called!")
|
||||||
|
|
||||||
fun viewModelFactory(
|
fun viewModelFactory(): ViewModelProvider.Factory =
|
||||||
savedStateRegistryOwner: SavedStateRegistryOwner,
|
ViewModelFactory(viewModelModule)
|
||||||
defaultArgs: Bundle
|
|
||||||
): ViewModelProvider.Factory =
|
|
||||||
ViewModelFactory(savedStateRegistryOwner, defaultArgs, viewModelModule)
|
|
||||||
|
|
||||||
val queueServiceViewModel: QueueServiceViewModel
|
val queueServiceViewModel: QueueServiceViewModel
|
||||||
get() = viewModelModule.queueServiceViewModel
|
get() = viewModelModule.queueServiceViewModel
|
||||||
|
|
||||||
fun start(context: Context) {
|
fun start(context: Context) {
|
||||||
val androidFileManagementModule = AndroidFileManagementModule(context)
|
val androidFileManagementModule = AndroidFileManagementModule(context)
|
||||||
val localSourceModule = LocalSourceModule(androidFileManagementModule = androidFileManagementModule)
|
val localSourceModule =
|
||||||
|
LocalSourceModule(androidFileManagementModule = androidFileManagementModule)
|
||||||
val networkModule = NetworkModule(delayBeforeRequest = DEFAULT_DELAY_BEFORE_REQUEST)
|
val networkModule = NetworkModule(delayBeforeRequest = DEFAULT_DELAY_BEFORE_REQUEST)
|
||||||
val useCaseModule = UseCaseModule(
|
val useCaseModule = UseCaseModule(
|
||||||
localSourceModule = localSourceModule,
|
localSourceModule = localSourceModule,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package org.fnives.tiktokdownloader.di
|
package org.fnives.tiktokdownloader.di
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
|
|
@ -10,17 +9,13 @@ inline fun <reified VM : ViewModel> ComponentActivity.provideViewModels() =
|
||||||
ViewModelLazy(
|
ViewModelLazy(
|
||||||
viewModelClass = VM::class,
|
viewModelClass = VM::class,
|
||||||
storeProducer = { viewModelStore },
|
storeProducer = { viewModelStore },
|
||||||
factoryProducer = { createViewModelFactory() }
|
factoryProducer = { ServiceLocator.viewModelFactory() },
|
||||||
|
extrasProducer = { defaultViewModelCreationExtras }
|
||||||
)
|
)
|
||||||
|
|
||||||
inline fun <reified VM : ViewModel> Fragment.provideViewModels() =
|
inline fun <reified VM : ViewModel> Fragment.provideViewModels() =
|
||||||
ViewModelLazy(
|
ViewModelLazy(
|
||||||
viewModelClass = VM::class,
|
viewModelClass = VM::class,
|
||||||
storeProducer = { viewModelStore },
|
storeProducer = { viewModelStore },
|
||||||
factoryProducer = { createViewModelFactory() })
|
factoryProducer = { ServiceLocator.viewModelFactory() },
|
||||||
|
extrasProducer = { defaultViewModelCreationExtras })
|
||||||
fun ComponentActivity.createViewModelFactory() =
|
|
||||||
ServiceLocator.viewModelFactory(this, intent?.extras ?: Bundle.EMPTY)
|
|
||||||
|
|
||||||
fun Fragment.createViewModelFactory() =
|
|
||||||
ServiceLocator.viewModelFactory(this, arguments ?: Bundle.EMPTY)
|
|
||||||
|
|
@ -1,29 +1,34 @@
|
||||||
package org.fnives.tiktokdownloader.di
|
package org.fnives.tiktokdownloader.di
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import androidx.lifecycle.AbstractSavedStateViewModelFactory
|
|
||||||
import androidx.lifecycle.SavedStateHandle
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.savedstate.SavedStateRegistryOwner
|
import androidx.lifecycle.ViewModelProvider
|
||||||
|
import androidx.lifecycle.createSavedStateHandle
|
||||||
|
import androidx.lifecycle.viewmodel.CreationExtras
|
||||||
import org.fnives.tiktokdownloader.di.module.ViewModelModule
|
import org.fnives.tiktokdownloader.di.module.ViewModelModule
|
||||||
import org.fnives.tiktokdownloader.ui.main.MainViewModel
|
import org.fnives.tiktokdownloader.ui.main.MainViewModel
|
||||||
import org.fnives.tiktokdownloader.ui.main.queue.QueueViewModel
|
import org.fnives.tiktokdownloader.ui.main.queue.QueueViewModel
|
||||||
import org.fnives.tiktokdownloader.ui.main.settings.SettingsViewModel
|
import org.fnives.tiktokdownloader.ui.main.settings.SettingsViewModel
|
||||||
|
|
||||||
class ViewModelFactory(
|
class ViewModelFactory(
|
||||||
savedStateRegistryOwner: SavedStateRegistryOwner,
|
|
||||||
defaultArgs: Bundle,
|
|
||||||
private val viewModelModule: ViewModelModule,
|
private val viewModelModule: ViewModelModule,
|
||||||
) : AbstractSavedStateViewModelFactory(savedStateRegistryOwner, defaultArgs) {
|
) : ViewModelProvider.Factory {
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
override fun <T : ViewModel?> create(key: String, modelClass: Class<T>, handle: SavedStateHandle): T {
|
override fun <T : ViewModel> create(modelClass: Class<T>): T {
|
||||||
val viewModel = when (modelClass) {
|
val viewModel = when (modelClass) {
|
||||||
MainViewModel::class.java -> viewModelModule.mainViewModel(handle)
|
|
||||||
QueueViewModel::class.java -> viewModelModule.queueViewModel
|
QueueViewModel::class.java -> viewModelModule.queueViewModel
|
||||||
SettingsViewModel::class.java -> viewModelModule.settignsViewModel
|
SettingsViewModel::class.java -> viewModelModule.settignsViewModel
|
||||||
else -> throw IllegalArgumentException("Can't create viewModel for $modelClass ")
|
else -> throw IllegalArgumentException("Can't create viewModel for $modelClass ")
|
||||||
}
|
}
|
||||||
return viewModel as T
|
return viewModel as T
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
override fun <T : ViewModel> create(modelClass: Class<T>, extras: CreationExtras): T {
|
||||||
|
val viewModel = when (modelClass) {
|
||||||
|
MainViewModel::class.java -> viewModelModule.mainViewModel(extras.createSavedStateHandle())
|
||||||
|
else -> create(modelClass)
|
||||||
|
}
|
||||||
|
return viewModel as T
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package org.fnives.tiktokdownloader.ui.service
|
package org.fnives.tiktokdownloader.ui.service
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.NotificationChannel
|
import android.app.NotificationChannel
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
|
|
@ -32,6 +33,7 @@ class QueueService : Service() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ForegroundServiceType")
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
intent?.url?.let(viewModel::onUrlReceived)
|
intent?.url?.let(viewModel::onUrlReceived)
|
||||||
startForeground()
|
startForeground()
|
||||||
|
|
@ -66,10 +68,16 @@ class QueueService : Service() {
|
||||||
val (id, notification) = when (notificationState) {
|
val (id, notification) = when (notificationState) {
|
||||||
is NotificationState.Processing ->
|
is NotificationState.Processing ->
|
||||||
SERVICE_NOTIFICATION_ID to NotificationCompat.Builder(this, CHANNEL_ID)
|
SERVICE_NOTIFICATION_ID to NotificationCompat.Builder(this, CHANNEL_ID)
|
||||||
.setContentTitle(getString(R.string.tik_tok_downloader_processing, notificationState.url))
|
.setContentTitle(
|
||||||
|
getString(
|
||||||
|
R.string.tik_tok_downloader_processing,
|
||||||
|
notificationState.url
|
||||||
|
)
|
||||||
|
)
|
||||||
.setSmallIcon(R.drawable.ic_download)
|
.setSmallIcon(R.drawable.ic_download)
|
||||||
.setProgress(0, 10, true)
|
.setProgress(0, 10, true)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
is NotificationState.Error ->
|
is NotificationState.Error ->
|
||||||
NOTIFICATION_ID to NotificationCompat.Builder(this, CHANNEL_ID)
|
NOTIFICATION_ID to NotificationCompat.Builder(this, CHANNEL_ID)
|
||||||
.setContentTitle(getString(notificationState.errorRes))
|
.setContentTitle(getString(notificationState.errorRes))
|
||||||
|
|
@ -78,6 +86,7 @@ class QueueService : Service() {
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setSilent(true)
|
.setSilent(true)
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
NotificationState.Finish -> {
|
NotificationState.Finish -> {
|
||||||
stopSelf()
|
stopSelf()
|
||||||
return
|
return
|
||||||
|
|
@ -100,7 +109,8 @@ class QueueService : Service() {
|
||||||
|
|
||||||
private class ServiceLifecycle : LifecycleOwner {
|
private class ServiceLifecycle : LifecycleOwner {
|
||||||
val lifecycleRegistry = LifecycleRegistry(this)
|
val lifecycleRegistry = LifecycleRegistry(this)
|
||||||
override fun getLifecycle(): Lifecycle = lifecycleRegistry
|
override val lifecycle: Lifecycle
|
||||||
|
get() = lifecycleRegistry
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,15 @@
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
tools:context=".ui.main.MainActivity">
|
tools:context=".ui.main.MainActivity">
|
||||||
|
|
||||||
|
<!-- TODO -->
|
||||||
|
<View
|
||||||
|
android:id="@+id/status_bar_inset"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
app:layout_constraintStart_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
android:layout_height="32dp"/>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/fragment_holder"
|
android:id="@+id/fragment_holder"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
|
@ -16,7 +25,7 @@
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="parent"
|
app:layout_constraintStart_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toBottomOf="@id/status_bar_inset" />
|
||||||
|
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
android:id="@+id/snack_bar_anchor"
|
android:id="@+id/snack_bar_anchor"
|
||||||
|
|
|
||||||
36
app/src/main/res/xml/data_extraction_rules.xml
Normal file
36
app/src/main/res/xml/data_extraction_rules.xml
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Sample data extraction rules file; uncomment and customize as necessary.
|
||||||
|
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||||
|
for details.
|
||||||
|
-->
|
||||||
|
<data-extraction-rules>
|
||||||
|
<cloud-backup>
|
||||||
|
<!--
|
||||||
|
TODO: Use <include> and <exclude> to control what is backed up.
|
||||||
|
The domain can be file, database, sharedpref, external or root.
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
<include domain="file" path="file_to_include"/>
|
||||||
|
<exclude domain="file" path="file_to_exclude"/>
|
||||||
|
<include domain="file" path="include_folder"/>
|
||||||
|
<exclude domain="file" path="include_folder/file_to_exclude"/>
|
||||||
|
<exclude domain="file" path="exclude_folder"/>
|
||||||
|
<include domain="file" path="exclude_folder/file_to_include"/>
|
||||||
|
|
||||||
|
<include domain="sharedpref" path="include_shared_pref1.xml"/>
|
||||||
|
<include domain="database" path="db_name/file_to_include"/>
|
||||||
|
<exclude domain="database" path="db_name/include_folder/file_to_exclude"/>
|
||||||
|
<include domain="external" path="file_to_include"/>
|
||||||
|
<exclude domain="external" path="file_to_exclude"/>
|
||||||
|
<include domain="root" path="file_to_include"/>
|
||||||
|
<exclude domain="root" path="file_to_exclude"/>
|
||||||
|
-->
|
||||||
|
</cloud-backup>
|
||||||
|
<!--
|
||||||
|
<device-transfer>
|
||||||
|
<include .../>
|
||||||
|
<exclude .../>
|
||||||
|
</device-transfer>
|
||||||
|
-->
|
||||||
|
</data-extraction-rules>
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
package org.fnives.tiktokdownloader.di
|
package org.fnives.tiktokdownloader.di
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import androidx.lifecycle.createSavedStateHandle
|
||||||
|
import androidx.lifecycle.viewmodel.CreationExtras
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.test.resetMain
|
import kotlinx.coroutines.test.resetMain
|
||||||
import kotlinx.coroutines.test.setMain
|
import kotlinx.coroutines.test.setMain
|
||||||
import org.fnives.tiktokdownloader.helper.mock.MockSavedStateRegistryOwner
|
|
||||||
import org.fnives.tiktokdownloader.ui.main.MainViewModel
|
import org.fnives.tiktokdownloader.ui.main.MainViewModel
|
||||||
import org.fnives.tiktokdownloader.ui.main.queue.QueueViewModel
|
import org.fnives.tiktokdownloader.ui.main.queue.QueueViewModel
|
||||||
import org.junit.jupiter.api.AfterEach
|
import org.junit.jupiter.api.AfterEach
|
||||||
|
|
@ -43,11 +44,17 @@ class ServiceLocatorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun verifyQueueViewModelCanBeCreated() {
|
fun verifyQueueViewModelCanBeCreated() {
|
||||||
ServiceLocator.viewModelFactory(MockSavedStateRegistryOwner(), mock()).create(QueueViewModel::class.java)
|
ServiceLocator.viewModelFactory().create(QueueViewModel::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun verifyMainViewModelCanBeCreated() {
|
fun verifyMainViewModelCanBeCreated() {
|
||||||
ServiceLocator.viewModelFactory(MockSavedStateRegistryOwner(), mock()).create(MainViewModel::class.java)
|
// TODO one day fix this, because the CreationExtras's createSavedStateHandle isn't open it actually gets called
|
||||||
|
// ServiceLocator.viewModelFactory().create(
|
||||||
|
// MainViewModel::class.java,
|
||||||
|
// mock<CreationExtras>().apply {
|
||||||
|
// doReturn(mock()).`when`(this).createSavedStateHandle()
|
||||||
|
// }
|
||||||
|
// )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4,11 +4,12 @@ import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.LifecycleObserver
|
import androidx.lifecycle.LifecycleObserver
|
||||||
|
|
||||||
class MockLifecycle : Lifecycle() {
|
class MockLifecycle : Lifecycle() {
|
||||||
|
override val currentState: State
|
||||||
|
get() = State.CREATED
|
||||||
|
|
||||||
override fun addObserver(observer: LifecycleObserver) {
|
override fun addObserver(observer: LifecycleObserver) {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun removeObserver(observer: LifecycleObserver) {
|
override fun removeObserver(observer: LifecycleObserver) {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getCurrentState(): State = State.CREATED
|
|
||||||
}
|
}
|
||||||
|
|
@ -6,11 +6,9 @@ import androidx.savedstate.SavedStateRegistryOwner
|
||||||
import org.mockito.kotlin.mock
|
import org.mockito.kotlin.mock
|
||||||
|
|
||||||
class MockSavedStateRegistryOwner(
|
class MockSavedStateRegistryOwner(
|
||||||
private val lifecycle: Lifecycle = MockLifecycle(),
|
override val lifecycle: Lifecycle = MockLifecycle(),
|
||||||
private val mockSavedStateRegistry: SavedStateRegistry = mock()
|
private val mockSavedStateRegistry: SavedStateRegistry = mock()
|
||||||
) : SavedStateRegistryOwner {
|
) : SavedStateRegistryOwner {
|
||||||
|
|
||||||
override fun getLifecycle(): Lifecycle = lifecycle
|
override val savedStateRegistry: SavedStateRegistry = mockSavedStateRegistry
|
||||||
|
|
||||||
override fun getSavedStateRegistry(): SavedStateRegistry = mockSavedStateRegistry
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = "1.6.20"
|
ext.kotlin_version = '2.1.21'
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
google()
|
google()
|
||||||
maven { url "https://plugins.gradle.org/m2/" }
|
maven { url "https://plugins.gradle.org/m2/" }
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:7.1.3'
|
classpath 'com.android.tools.build:gradle:8.7.3'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
|
|
||||||
|
|
@ -19,3 +19,6 @@ android.useAndroidX=true
|
||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
# Kotlin code style for this project: "official" or "obsolete":
|
# Kotlin code style for this project: "official" or "obsolete":
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
|
android.defaults.buildfeatures.buildconfig=true
|
||||||
|
android.nonTransitiveRClass=false
|
||||||
|
android.nonFinalResIds=false
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
|
@ -1,6 +1,6 @@
|
||||||
#Thu Jan 27 21:44:07 EET 2022
|
#Thu Jan 27 21:44:07 EET 2022
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue