diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt index 965075bf302..48427d17435 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/FeedFragment.kt @@ -25,6 +25,7 @@ import android.content.Intent import android.content.SharedPreferences import android.os.Bundle import android.os.Parcelable +import android.util.Log import android.view.LayoutInflater import android.view.Menu import android.view.MenuInflater @@ -464,7 +465,7 @@ class FeedFragment : BaseStateFragment() { errors.subList(i + 1, errors.size) ) }, - { throwable -> throwable.printStackTrace() } + { throwable -> Log.e(TAG, "Unable to process", throwable) } ) return // this will be called on the remaining errors by handleFeedNotAvailable() } diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index 5435b9f819b..fb903813c1a 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -695,7 +695,7 @@ && isPlaybackResumeEnabled(this) }, error -> { if (DEBUG) { - error.printStackTrace(); + Log.w(TAG, "Failed to start playback", error); } // In case any error we can start playback without history initPlayback(newQueue, repeatMode, playbackSpeed, playbackPitch, @@ -4184,8 +4184,7 @@ private boolean isLive() { } catch (@NonNull final IndexOutOfBoundsException e) { // Why would this even happen =(... but lets log it anyway, better safe than sorry if (DEBUG) { - Log.d(TAG, "player.isCurrentWindowDynamic() failed: " + e.getMessage()); - e.printStackTrace(); + Log.d(TAG, "player.isCurrentWindowDynamic() failed: ", e); } return false; } diff --git a/app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java b/app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java index 998324c9c66..e55c596b800 100644 --- a/app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java +++ b/app/src/main/java/org/schabi/newpipe/player/event/PlayerGestureListener.java @@ -69,26 +69,18 @@ public void onSingleTap(@NotNull final MainPlayer.PlayerType playerType) { if (DEBUG) { Log.d(TAG, "onSingleTap called with playerType = [" + player.getPlayerType() + "]"); } - if (playerType == MainPlayer.PlayerType.POPUP) { - if (player.isControlsVisible()) { - player.hideControls(100, 100); - } else { - player.getPlayPauseButton().requestFocus(); - player.showControlsThenHide(); - } - - } else /* playerType == MainPlayer.PlayerType.VIDEO */ { + if (player.isControlsVisible()) { + player.hideControls(150, 0); + return; + } + // -- Controls are not visible -- - if (player.isControlsVisible()) { - player.hideControls(150, 0); - } else { - if (player.getCurrentState() == Player.STATE_COMPLETED) { - player.showControls(0); - } else { - player.showControlsThenHide(); - } - } + // When player is completed show controls and don't hide them later + if (player.getCurrentState() == Player.STATE_COMPLETED) { + player.showControls(0); + } else { + player.showControlsThenHide(); } } @@ -103,6 +95,8 @@ public void onScroll(@NotNull final MainPlayer.PlayerType playerType, + player.getPlayerType() + "], portion = [" + portion + "]"); } if (playerType == MainPlayer.PlayerType.VIDEO) { + + // -- Brightness and Volume control -- final boolean isBrightnessGestureEnabled = PlayerHelper.isBrightnessGestureEnabled(service); final boolean isVolumeGestureEnabled = PlayerHelper.isVolumeGestureEnabled(service); @@ -121,15 +115,14 @@ public void onScroll(@NotNull final MainPlayer.PlayerType playerType, } } else /* MainPlayer.PlayerType.POPUP */ { + + // -- Determine if the ClosingOverlayView (red X) has to be shown or hidden -- final View closingOverlayView = player.getClosingOverlayView(); - if (player.isInsideClosingRadius(movingEvent)) { - if (closingOverlayView.getVisibility() == View.GONE) { - animate(closingOverlayView, true, 200); - } - } else { - if (closingOverlayView.getVisibility() == View.VISIBLE) { - animate(closingOverlayView, false, 200); - } + final boolean showClosingOverlayView = player.isInsideClosingRadius(movingEvent); + // Check if an view is in expected state and if not animate it into the correct state + final int expectedVisibility = showClosingOverlayView ? View.VISIBLE : View.GONE; + if (closingOverlayView.getVisibility() != expectedVisibility) { + animate(closingOverlayView, showClosingOverlayView, 200); } } } @@ -210,11 +203,12 @@ public void onScrollEnd(@NotNull final MainPlayer.PlayerType playerType, Log.d(TAG, "onScrollEnd called with playerType = [" + player.getPlayerType() + "]"); } - if (playerType == MainPlayer.PlayerType.VIDEO) { - if (DEBUG) { - Log.d(TAG, "onScrollEnd() called"); - } + if (player.isControlsVisible() && player.getCurrentState() == STATE_PLAYING) { + player.hideControls(DEFAULT_CONTROLS_DURATION, DEFAULT_CONTROLS_HIDE_TIME); + } + + if (playerType == MainPlayer.PlayerType.VIDEO) { if (player.getVolumeRelativeLayout().getVisibility() == View.VISIBLE) { animate(player.getVolumeRelativeLayout(), false, 200, SCALE_AND_ALPHA, 200); @@ -223,15 +217,7 @@ public void onScrollEnd(@NotNull final MainPlayer.PlayerType playerType, animate(player.getBrightnessRelativeLayout(), false, 200, SCALE_AND_ALPHA, 200); } - - if (player.isControlsVisible() && player.getCurrentState() == STATE_PLAYING) { - player.hideControls(DEFAULT_CONTROLS_DURATION, DEFAULT_CONTROLS_HIDE_TIME); - } - } else { - if (player.isControlsVisible() && player.getCurrentState() == STATE_PLAYING) { - player.hideControls(DEFAULT_CONTROLS_DURATION, DEFAULT_CONTROLS_HIDE_TIME); - } - + } else /* Popup-Player */ { if (player.isInsideClosingRadius(event)) { player.closePopup(); } else if (!player.isPopupClosing()) { diff --git a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsManager.kt b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsManager.kt index 6bc63a56aa9..3ac2756952e 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsManager.kt +++ b/app/src/main/java/org/schabi/newpipe/settings/ContentSettingsManager.kt @@ -1,6 +1,7 @@ package org.schabi.newpipe.settings import android.content.SharedPreferences +import android.util.Log import org.schabi.newpipe.streams.io.SharpOutputStream import org.schabi.newpipe.streams.io.StoredFileHelper import org.schabi.newpipe.util.ZipHelper @@ -13,6 +14,9 @@ import java.io.ObjectOutputStream import java.util.zip.ZipOutputStream class ContentSettingsManager(private val fileLocator: NewPipeFileLocator) { + companion object { + const val TAG = "ContentSetManager" + } /** * Exports given [SharedPreferences] to the file in given outputPath. @@ -31,7 +35,7 @@ class ContentSettingsManager(private val fileLocator: NewPipeFileLocator) { output.flush() } } catch (e: IOException) { - e.printStackTrace() + Log.e(TAG, "Unable to exportDatabase", e) } ZipHelper.addFileToZip(outZip, fileLocator.settings.path, "newpipe.settings") @@ -101,9 +105,9 @@ class ContentSettingsManager(private val fileLocator: NewPipeFileLocator) { preferenceEditor.commit() } } catch (e: IOException) { - e.printStackTrace() + Log.e(TAG, "Unable to loadSharedPreferences", e) } catch (e: ClassNotFoundException) { - e.printStackTrace() + Log.e(TAG, "Unable to loadSharedPreferences", e) } } } diff --git a/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java b/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java index 8cf5a4cdf83..05e69408a9d 100644 --- a/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java +++ b/app/src/main/java/org/schabi/newpipe/util/TLSSocketFactoryCompat.java @@ -10,9 +10,8 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import static org.schabi.newpipe.MainActivity.DEBUG; +import android.util.Log; /** @@ -21,6 +20,7 @@ */ public class TLSSocketFactoryCompat extends SSLSocketFactory { + private static final String TAG = "TLSSocketFactoryCom"; private static TLSSocketFactoryCompat instance = null; @@ -32,14 +32,6 @@ public TLSSocketFactoryCompat() throws KeyManagementException, NoSuchAlgorithmEx internalSSLSocketFactory = context.getSocketFactory(); } - - public TLSSocketFactoryCompat(final TrustManager[] tm) - throws KeyManagementException, NoSuchAlgorithmException { - final SSLContext context = SSLContext.getInstance("TLS"); - context.init(null, tm, new java.security.SecureRandom()); - internalSSLSocketFactory = context.getSocketFactory(); - } - public static TLSSocketFactoryCompat getInstance() throws NoSuchAlgorithmException, KeyManagementException { if (instance != null) { @@ -53,9 +45,7 @@ public static void setAsDefault() { try { HttpsURLConnection.setDefaultSSLSocketFactory(getInstance()); } catch (NoSuchAlgorithmException | KeyManagementException e) { - if (DEBUG) { - e.printStackTrace(); - } + Log.e(TAG, "Unable to setAsDefault", e); } }