diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml index bab6aec8..42e3dc32 100644 --- a/.idea/assetWizardSettings.xml +++ b/.idea/assetWizardSettings.xml @@ -5,7 +5,304 @@ - + + + @@ -33,9 +330,10 @@ diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index d53f09fd..24252699 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -7,11 +7,11 @@ - + - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index cef79b0f..323d432d 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -35,6 +35,7 @@ + @@ -48,6 +49,8 @@ + + @@ -88,6 +91,7 @@ + diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png new file mode 100644 index 00000000..bae97906 Binary files /dev/null and b/app/src/main/ic_launcher-playstore.png differ diff --git a/app/src/main/java/com/deniscerri/ytdlnis/DownloaderService.java b/app/src/main/java/com/deniscerri/ytdlnis/DownloaderService.java index 0d584aff..da53c180 100644 --- a/app/src/main/java/com/deniscerri/ytdlnis/DownloaderService.java +++ b/app/src/main/java/com/deniscerri/ytdlnis/DownloaderService.java @@ -7,15 +7,14 @@ import android.app.Service; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; -import android.media.MediaScannerConnection; 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; @@ -24,6 +23,7 @@ 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.Collections; import java.util.LinkedList; @@ -31,7 +31,6 @@ import java.util.Map; 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; @@ -48,15 +47,19 @@ public class DownloaderService extends Service { private final NotificationUtil notificationUtil = App.notificationUtil; private Context context; public String downloadProcessID = "processID"; - private static final String TAG = "DownloaderService"; + private int downloadNotificationID; private final DownloadProgressCallback callback = (progress, etaInSeconds, line) -> { downloadInfo.setProgress((int) progress); downloadInfo.setOutputLine(line); downloadInfo.setDownloadQueue(downloadQueue); - notificationUtil.updateDownloadNotification(NotificationUtil.DOWNLOAD_NOTIFICATION_ID, - line, (int) progress, downloadQueue.size(), downloadQueue.peek().getTitle()); + String title = getString(R.string.running_ytdlp_command); + if (!downloadQueue.isEmpty()){ + title = downloadQueue.peek().getTitle(); + } + notificationUtil.updateDownloadNotification(downloadNotificationID, + line, (int) progress, downloadQueue.size(), title); try{ for (Activity activity: activities.keySet()){ @@ -79,8 +82,8 @@ public class DownloaderService extends Service { @Nullable @Override public IBinder onBind(Intent intent) { - Intent theIntent = new Intent(this, MainActivity.class); - PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, theIntent, PendingIntent.FLAG_IMMUTABLE); + Intent theIntent; + PendingIntent pendingIntent; if(intent.getBooleanExtra("rebind", false)){ return binder; @@ -89,20 +92,28 @@ public class DownloaderService extends Service { int id = intent.getIntExtra("id", 1); switch (id){ case NotificationUtil.DOWNLOAD_NOTIFICATION_ID: - ArrayList queue = (ArrayList