From b1429366da3b89487c7f842f2a14ae46052005ab Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Fri, 24 Aug 2018 17:42:35 +0200 Subject: [PATCH] fixes acording to code review fixes moreacording to code review fixed link handling once more --- app/build.gradle | 2 +- .../newpipe/player/BackgroundPlayer.java | 6 ++++++ .../newpipe/player/ServicePlayerActivity.java | 4 ---- .../newpipe/settings/NewPipeSettings.java | 21 +++++++++++-------- .../giga/get/DownloadManagerImpl.java | 8 ++----- app/src/main/res/values/strings.xml | 2 +- build.gradle | 2 +- 7 files changed, 23 insertions(+), 22 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 8170869d1..354dbaa0e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -55,7 +55,7 @@ dependencies { exclude module: 'support-annotations' } - implementation 'com.github.TeamNewPipe:NewPipeExtractor:e662c97433c950' + implementation 'com.github.TeamNewPipe:NewPipeExtractor:fef71aeccc37' testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.8.9' diff --git a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java index de981f283..91faa1014 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BackgroundPlayer.java @@ -26,6 +26,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.graphics.Bitmap; +import android.os.Build; import android.os.IBinder; import android.support.annotation.NonNull; import android.support.annotation.Nullable; @@ -309,6 +310,7 @@ public final class BackgroundPlayer extends Service { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { super.onLoadingComplete(imageUri, view, loadedImage); + resetNotification(); updateNotificationThumbnail(); updateNotification(-1); } @@ -341,6 +343,8 @@ public final class BackgroundPlayer extends Service { updateProgress(currentProgress, duration, bufferPercent); if (!shouldUpdateOnProgress) return; + resetNotification(); + if(Build.VERSION.SDK_INT >= 26 /*Oreo*/) updateNotificationThumbnail(); if (bigNotRemoteView != null) { bigNotRemoteView.setProgressBar(R.id.notificationProgressBar, duration, currentProgress, false); bigNotRemoteView.setTextViewText(R.id.notificationTime, getTimeString(currentProgress) + " / " + getTimeString(duration)); @@ -529,6 +533,8 @@ public final class BackgroundPlayer extends Service { @Override public void onPlaying() { super.onPlaying(); + resetNotification(); + updateNotificationThumbnail(); updateNotification(R.drawable.ic_pause_white); lockManager.acquireWifiAndCpu(); } diff --git a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java index 0d08c47b2..94305e6c4 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ServicePlayerActivity.java @@ -1,10 +1,8 @@ package org.schabi.newpipe.player; import android.content.ComponentName; -import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; -import android.graphics.Point; import android.os.Build; import android.os.Bundle; import android.os.IBinder; @@ -15,12 +13,10 @@ import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; import android.support.v7.widget.helper.ItemTouchHelper; import android.util.Log; -import android.view.Display; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.view.WindowManager; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.PopupMenu; diff --git a/app/src/main/java/org/schabi/newpipe/settings/NewPipeSettings.java b/app/src/main/java/org/schabi/newpipe/settings/NewPipeSettings.java index 08ec74d17..2a0e2645b 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/NewPipeSettings.java +++ b/app/src/main/java/org/schabi/newpipe/settings/NewPipeSettings.java @@ -71,7 +71,7 @@ public class NewPipeSettings { } public static File getVideoDownloadFolder(Context context) { - return getFolder(context, R.string.download_path_key, Environment.DIRECTORY_MOVIES); + return getDir(context, R.string.download_path_key, Environment.DIRECTORY_MOVIES); } public static String getVideoDownloadPath(Context context) { @@ -81,7 +81,7 @@ public class NewPipeSettings { } public static File getAudioDownloadFolder(Context context) { - return getFolder(context, R.string.download_path_audio_key, Environment.DIRECTORY_MUSIC); + return getDir(context, R.string.download_path_audio_key, Environment.DIRECTORY_MUSIC); } public static String getAudioDownloadPath(Context context) { @@ -90,21 +90,21 @@ public class NewPipeSettings { return prefs.getString(key, Environment.DIRECTORY_MUSIC); } - private static File getFolder(Context context, int keyID, String defaultDirectoryName) { + private static File getDir(Context context, int keyID, String defaultDirectoryName) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); final String key = context.getString(keyID); String downloadPath = prefs.getString(key, null); if ((downloadPath != null) && (!downloadPath.isEmpty())) return new File(downloadPath.trim()); - final File folder = getFolder(defaultDirectoryName); + final File dir = getDir(defaultDirectoryName); SharedPreferences.Editor spEditor = prefs.edit(); - spEditor.putString(key, new File(folder, "NewPipe").getAbsolutePath()); + spEditor.putString(key, getNewPipeChildFolderPathForDir(dir)); spEditor.apply(); - return folder; + return dir; } @NonNull - private static File getFolder(String defaultDirectoryName) { + private static File getDir(String defaultDirectoryName) { return new File(Environment.getExternalStorageDirectory(), defaultDirectoryName); } @@ -115,9 +115,12 @@ public class NewPipeSettings { } private static void resetDownloadFolder(SharedPreferences prefs, String key, String defaultDirectoryName) { - final File folder = getFolder(defaultDirectoryName); SharedPreferences.Editor spEditor = prefs.edit(); - spEditor.putString(key, new File(folder, "NewPipe").getAbsolutePath()); + spEditor.putString(key, getNewPipeChildFolderPathForDir(getDir(defaultDirectoryName))); spEditor.apply(); } + + private static String getNewPipeChildFolderPathForDir(File dir) { + return new File(dir, "NewPipe").getAbsolutePath(); + } } diff --git a/app/src/main/java/us/shandian/giga/get/DownloadManagerImpl.java b/app/src/main/java/us/shandian/giga/get/DownloadManagerImpl.java index 550bd420d..3294f5164 100755 --- a/app/src/main/java/us/shandian/giga/get/DownloadManagerImpl.java +++ b/app/src/main/java/us/shandian/giga/get/DownloadManagerImpl.java @@ -1,18 +1,13 @@ package us.shandian.giga.get; -import android.app.AlertDialog; import android.content.Context; -import android.content.DialogInterface; import android.content.Intent; -import android.content.SharedPreferences; import android.os.Handler; -import android.preference.PreferenceManager; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.util.Log; -import org.schabi.newpipe.R; import org.schabi.newpipe.download.ExtSDDownloadFailedActivity; -import org.schabi.newpipe.settings.NewPipeSettings; import java.io.File; import java.io.FilenameFilter; @@ -36,6 +31,7 @@ public class DownloadManagerImpl implements DownloadManager { private final DownloadDataSource mDownloadDataSource; private final ArrayList mMissions = new ArrayList<>(); + @NonNull private final Context context; /** diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0e72ecd35..eaeeb2685 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -171,7 +171,7 @@ Error External storage not available. - Download to external SD Card is not possible yet. Should the download place be reseted? + Download to external SD Card is not possible yet. Should the download place be reset? Network error Could not load all thumbnails Could not decrypt video URL signature diff --git a/build.gradle b/build.gradle index 0448ed61e..20c8a0dfc 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.3' + classpath 'com.android.tools.build:gradle:3.1.4' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files