1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-25 04:22:30 +01:00

fixes acording to code review

fixes moreacording to code review

fixed link handling once more
This commit is contained in:
Christian Schabesberger 2018-08-24 17:42:35 +02:00
parent 2003f51d49
commit b1429366da
7 changed files with 23 additions and 22 deletions

View File

@ -55,7 +55,7 @@ dependencies {
exclude module: 'support-annotations' exclude module: 'support-annotations'
} }
implementation 'com.github.TeamNewPipe:NewPipeExtractor:e662c97433c950' implementation 'com.github.TeamNewPipe:NewPipeExtractor:fef71aeccc37'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.8.9' testImplementation 'org.mockito:mockito-core:2.8.9'

View File

@ -26,6 +26,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -309,6 +310,7 @@ public final class BackgroundPlayer extends Service {
@Override @Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
super.onLoadingComplete(imageUri, view, loadedImage); super.onLoadingComplete(imageUri, view, loadedImage);
resetNotification();
updateNotificationThumbnail(); updateNotificationThumbnail();
updateNotification(-1); updateNotification(-1);
} }
@ -341,6 +343,8 @@ public final class BackgroundPlayer extends Service {
updateProgress(currentProgress, duration, bufferPercent); updateProgress(currentProgress, duration, bufferPercent);
if (!shouldUpdateOnProgress) return; if (!shouldUpdateOnProgress) return;
resetNotification();
if(Build.VERSION.SDK_INT >= 26 /*Oreo*/) updateNotificationThumbnail();
if (bigNotRemoteView != null) { if (bigNotRemoteView != null) {
bigNotRemoteView.setProgressBar(R.id.notificationProgressBar, duration, currentProgress, false); bigNotRemoteView.setProgressBar(R.id.notificationProgressBar, duration, currentProgress, false);
bigNotRemoteView.setTextViewText(R.id.notificationTime, getTimeString(currentProgress) + " / " + getTimeString(duration)); bigNotRemoteView.setTextViewText(R.id.notificationTime, getTimeString(currentProgress) + " / " + getTimeString(duration));
@ -529,6 +533,8 @@ public final class BackgroundPlayer extends Service {
@Override @Override
public void onPlaying() { public void onPlaying() {
super.onPlaying(); super.onPlaying();
resetNotification();
updateNotificationThumbnail();
updateNotification(R.drawable.ic_pause_white); updateNotification(R.drawable.ic_pause_white);
lockManager.acquireWifiAndCpu(); lockManager.acquireWifiAndCpu();
} }

View File

@ -1,10 +1,8 @@
package org.schabi.newpipe.player; package org.schabi.newpipe.player;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.ServiceConnection; import android.content.ServiceConnection;
import android.graphics.Point;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; 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.Toolbar;
import android.support.v7.widget.helper.ItemTouchHelper; import android.support.v7.widget.helper.ItemTouchHelper;
import android.util.Log; import android.util.Log;
import android.view.Display;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.PopupMenu; import android.widget.PopupMenu;

View File

@ -71,7 +71,7 @@ public class NewPipeSettings {
} }
public static File getVideoDownloadFolder(Context context) { 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) { public static String getVideoDownloadPath(Context context) {
@ -81,7 +81,7 @@ public class NewPipeSettings {
} }
public static File getAudioDownloadFolder(Context context) { 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) { public static String getAudioDownloadPath(Context context) {
@ -90,21 +90,21 @@ public class NewPipeSettings {
return prefs.getString(key, Environment.DIRECTORY_MUSIC); 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); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
final String key = context.getString(keyID); final String key = context.getString(keyID);
String downloadPath = prefs.getString(key, null); String downloadPath = prefs.getString(key, null);
if ((downloadPath != null) && (!downloadPath.isEmpty())) return new File(downloadPath.trim()); 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(); SharedPreferences.Editor spEditor = prefs.edit();
spEditor.putString(key, new File(folder, "NewPipe").getAbsolutePath()); spEditor.putString(key, getNewPipeChildFolderPathForDir(dir));
spEditor.apply(); spEditor.apply();
return folder; return dir;
} }
@NonNull @NonNull
private static File getFolder(String defaultDirectoryName) { private static File getDir(String defaultDirectoryName) {
return new File(Environment.getExternalStorageDirectory(), defaultDirectoryName); return new File(Environment.getExternalStorageDirectory(), defaultDirectoryName);
} }
@ -115,9 +115,12 @@ public class NewPipeSettings {
} }
private static void resetDownloadFolder(SharedPreferences prefs, String key, String defaultDirectoryName) { private static void resetDownloadFolder(SharedPreferences prefs, String key, String defaultDirectoryName) {
final File folder = getFolder(defaultDirectoryName);
SharedPreferences.Editor spEditor = prefs.edit(); SharedPreferences.Editor spEditor = prefs.edit();
spEditor.putString(key, new File(folder, "NewPipe").getAbsolutePath()); spEditor.putString(key, getNewPipeChildFolderPathForDir(getDir(defaultDirectoryName)));
spEditor.apply(); spEditor.apply();
} }
private static String getNewPipeChildFolderPathForDir(File dir) {
return new File(dir, "NewPipe").getAbsolutePath();
}
} }

View File

@ -1,18 +1,13 @@
package us.shandian.giga.get; package us.shandian.giga.get;
import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Handler; import android.os.Handler;
import android.preference.PreferenceManager; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.util.Log; import android.util.Log;
import org.schabi.newpipe.R;
import org.schabi.newpipe.download.ExtSDDownloadFailedActivity; import org.schabi.newpipe.download.ExtSDDownloadFailedActivity;
import org.schabi.newpipe.settings.NewPipeSettings;
import java.io.File; import java.io.File;
import java.io.FilenameFilter; import java.io.FilenameFilter;
@ -36,6 +31,7 @@ public class DownloadManagerImpl implements DownloadManager {
private final DownloadDataSource mDownloadDataSource; private final DownloadDataSource mDownloadDataSource;
private final ArrayList<DownloadMission> mMissions = new ArrayList<>(); private final ArrayList<DownloadMission> mMissions = new ArrayList<>();
@NonNull
private final Context context; private final Context context;
/** /**

View File

@ -171,7 +171,7 @@
<!-- error strings --> <!-- error strings -->
<string name="general_error">Error</string> <string name="general_error">Error</string>
<string name="download_to_sdcard_error_title">External storage not available.</string> <string name="download_to_sdcard_error_title">External storage not available.</string>
<string name="download_to_sdcard_error_message">Download to external SD Card is not possible yet. Should the download place be reseted?</string> <string name="download_to_sdcard_error_message">Download to external SD Card is not possible yet. Should the download place be reset?</string>
<string name="network_error">Network error</string> <string name="network_error">Network error</string>
<string name="could_not_load_thumbnails">Could not load all thumbnails</string> <string name="could_not_load_thumbnails">Could not load all thumbnails</string>
<string name="youtube_signature_decryption_error">Could not decrypt video URL signature</string> <string name="youtube_signature_decryption_error">Could not decrypt video URL signature</string>

View File

@ -6,7 +6,7 @@ buildscript {
google() google()
} }
dependencies { 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 // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files