From 2a02175adee22fc17197c9ef4e5088c31bf0d649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20=C3=87erri?= <64997243+deniscerri@users.noreply.github.com> Date: Sun, 8 Jan 2023 16:49:24 +0100 Subject: [PATCH] cleanup --- .gitignore | 8 +- README.md | 2 +- app/build.gradle | 17 +- .../main/java/com/deniscerri/ytdlnis/App.kt | 6 - .../deniscerri/ytdlnis/DownloaderService.java | 515 +++++++++++++++ .../deniscerri/ytdlnis/DownloaderService.kt | 592 ------------------ .../com/deniscerri/ytdlnis/MainActivity.kt | 26 +- .../ytdlnis/page/CustomCommandActivity.java | 12 +- .../ytdlnis/page/DownloadsFragment.java | 27 +- .../page/settings/SettingsFragment.java | 359 +++++++++++ .../ytdlnis/page/settings/SettingsFragment.kt | 326 ---------- .../ytdlnis/service/IDownloaderService.java | 2 +- .../com/deniscerri/ytdlnis/util/FileUtil.kt | 110 +--- .../com/deniscerri/ytdlnis/util/InfoUtil.kt | 34 +- .../ytdlnis/util/NotificationUtil.kt | 68 +- .../com/deniscerri/ytdlnis/util/UpdateUtil.kt | 14 +- app/src/main/res/layout/fragment_more.xml | 3 +- app/src/main/res/layout/result_card.xml | 2 +- build.gradle | 9 +- 19 files changed, 959 insertions(+), 1173 deletions(-) create mode 100644 app/src/main/java/com/deniscerri/ytdlnis/DownloaderService.java delete mode 100644 app/src/main/java/com/deniscerri/ytdlnis/DownloaderService.kt create mode 100644 app/src/main/java/com/deniscerri/ytdlnis/page/settings/SettingsFragment.java delete mode 100644 app/src/main/java/com/deniscerri/ytdlnis/page/settings/SettingsFragment.kt diff --git a/.gitignore b/.gitignore index 09b993d0..93d25cf2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,13 @@ *.iml .gradle /local.properties -/.idea +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/caches +/.idea/tasks.xml +/.idea/gradle.xml +/.idea/dictionaries .DS_Store /build /captures diff --git a/README.md b/README.md index b0b8f806..144f508b 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ | Build | Latest Release | Downloads | Contribute | |-------|----------|------------|------------| -| ![CI](https://github.com/deniscerri/ytdlnis/actions/workflows/android.yml/badge.svg?branch=main&event=pull) | [![stable release](https://img.shields.io/github/release/deniscerri/ytdlnis.svg?maxAge=3600&label=download)](https://github.com/deniscerri/ytdlnis/releases/latest) | [![downloads](https://img.shields.io/github/downloads/deniscerri/ytdlnis/total?style=flat-square)](https://github.com/deniscerri/ytdlnis/releases) | [![Translation status](https://hosted.weblate.org/widgets/ytdlnis/-/svg-badge.svg)](https://hosted.weblate.org/engage/ytdlnis/?utm_source=widget) | +| ![CI](https://github.com/deniscerri/ytdlnis/actions/workflows/android.yml/badge.svg?branch=main&event=pull) | [![stable release](https://img.shields.io/github/release/deniscerri/ytdlnis.svg?maxAge=3600&label=download)](https://github.com/deniscerri/ytdlnis/releases) | [![downloads](https://img.shields.io/github/downloads/deniscerri/ytdlnis/total?style=flat-square)](https://img.shields.io/github/downloads/deniscerri/ytdlnis/total?style=flat-square) | [![Translation status](https://hosted.weblate.org/widgets/ytdlnis/-/svg-badge.svg)](https://hosted.weblate.org/engage/ytdlnis/?utm_source=widget) | diff --git a/app/build.gradle b/app/build.gradle index a32a83dc..524e3b39 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -30,7 +30,7 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" archivesBaseName = "YTDLnis-$versionName" ndk { - abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' + abiFilters 'armeabi-v7a', 'arm64-v8a' } vectorDrawables { useSupportLibrary true @@ -75,7 +75,7 @@ android { abi { enable true reset() - include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' + include 'armeabi-v7a', 'arm64-v8a' universalApk true } } @@ -91,9 +91,9 @@ dependencies { // implementation project(":library") // implementation project(":ffmpeg") - implementation "com.github.JunkFood02.youtubedl-android:library:$youtubedlAndroidVer" - implementation "com.github.JunkFood02.youtubedl-android:ffmpeg:$youtubedlAndroidVer" - implementation "com.github.JunkFood02.youtubedl-android:aria2c:$youtubedlAndroidVer" + implementation "com.github.yausername.youtubedl-android:library:$youtubedlAndroidVer" + implementation "com.github.yausername.youtubedl-android:ffmpeg:$youtubedlAndroidVer" + implementation "com.github.yausername.youtubedl-android:aria2c:$youtubedlAndroidVer" implementation "androidx.appcompat:appcompat:$appCompatVer" implementation "androidx.constraintlayout:constraintlayout:2.1.4" @@ -119,7 +119,7 @@ dependencies { implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0' implementation 'com.facebook.shimmer:shimmer:0.5.0' - implementation "androidx.work:work-runtime-ktx:$workVer" + implementation "androidx.work:work-runtime:$workVer" implementation "androidx.room:room-runtime:2.4.3" implementation "androidx.room:room-ktx:2.4.3" @@ -127,8 +127,7 @@ dependencies { androidTestImplementation "androidx.room:room-testing:2.4.3" implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1' implementation "androidx.compose.runtime:runtime:$composeVer" - androidTestImplementation "com.google.truth:truth:1.1.3" - api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutineVer" - api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVer" + + androidTestImplementation "com.google.truth:truth:1.1.3" } \ No newline at end of file diff --git a/app/src/main/java/com/deniscerri/ytdlnis/App.kt b/app/src/main/java/com/deniscerri/ytdlnis/App.kt index c8cddd94..308bf2a9 100644 --- a/app/src/main/java/com/deniscerri/ytdlnis/App.kt +++ b/app/src/main/java/com/deniscerri/ytdlnis/App.kt @@ -2,15 +2,10 @@ package com.deniscerri.ytdlnis import android.annotation.SuppressLint import android.app.Application -import android.content.Context -import android.content.pm.PackageInfo -import android.content.pm.PackageManager -import android.os.Build import android.util.Log import android.widget.Toast import androidx.preference.PreferenceManager import com.deniscerri.ytdlnis.util.NotificationUtil -import com.deniscerri.ytdlnis.util.UpdateUtil import com.google.android.material.color.DynamicColors import com.yausername.aria2c.Aria2c import com.yausername.ffmpeg.FFmpeg @@ -22,7 +17,6 @@ import io.reactivex.exceptions.UndeliverableException import io.reactivex.observers.DisposableCompletableObserver import io.reactivex.plugins.RxJavaPlugins import io.reactivex.schedulers.Schedulers -import java.io.File class App : Application() { override fun onCreate() { diff --git a/app/src/main/java/com/deniscerri/ytdlnis/DownloaderService.java b/app/src/main/java/com/deniscerri/ytdlnis/DownloaderService.java new file mode 100644 index 00000000..12a592be --- /dev/null +++ b/app/src/main/java/com/deniscerri/ytdlnis/DownloaderService.java @@ -0,0 +1,515 @@ +package com.deniscerri.ytdlnis; + +import android.app.Activity; +import android.app.Notification; +import android.app.PendingIntent; +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Binder; +import android.os.IBinder; +import android.util.Log; +import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import com.deniscerri.ytdlnis.database.Video; +import com.deniscerri.ytdlnis.page.CustomCommandActivity; +import com.deniscerri.ytdlnis.service.DownloadInfo; +import com.deniscerri.ytdlnis.service.IDownloaderListener; +import com.deniscerri.ytdlnis.service.IDownloaderService; +import com.deniscerri.ytdlnis.util.NotificationUtil; +import com.yausername.youtubedl_android.DownloadProgressCallback; +import com.yausername.youtubedl_android.YoutubeDL; +import com.yausername.youtubedl_android.YoutubeDLRequest; +import java.io.File; +import java.io.FileOutputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import io.reactivex.Observable; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.CompositeDisposable; +import io.reactivex.disposables.Disposable; +import io.reactivex.schedulers.Schedulers; + +public class DownloaderService extends Service { + + private LocalBinder binder = new LocalBinder(); + private Map> activities = new ConcurrentHashMap<>(); + private DownloadInfo downloadInfo = new DownloadInfo(); + private LinkedList