diff --git a/app/build.gradle b/app/build.gradle index 9648a67b7..80171be62 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -187,7 +187,6 @@ dependencies { implementation "androidx.lifecycle:lifecycle-livedata:${androidxLifecycleVersion}" implementation "androidx.lifecycle:lifecycle-viewmodel:${androidxLifecycleVersion}" - implementation "androidx.lifecycle:lifecycle-extensions:${androidxLifecycleVersion}" implementation "androidx.room:room-runtime:${androidxRoomVersion}" implementation "androidx.room:room-rxjava2:${androidxRoomVersion}" diff --git a/app/src/androidTest/java/org/schabi/newpipe/report/ErrorInfoTest.java b/app/src/androidTest/java/org/schabi/newpipe/report/ErrorInfoTest.java index 972737d25..a3aa28059 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/report/ErrorInfoTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/report/ErrorInfoTest.java @@ -2,9 +2,9 @@ package org.schabi.newpipe.report; import android.os.Parcel; +import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest; -import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; import org.schabi.newpipe.R; diff --git a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java index 3041c3d6c..81ba78ba9 100644 --- a/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java +++ b/app/src/main/java/org/schabi/newpipe/about/AboutActivity.java @@ -167,7 +167,7 @@ public class AboutActivity extends AppCompatActivity { */ public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(final FragmentManager fm) { - super(fm); + super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); } @Override diff --git a/app/src/main/java/org/schabi/newpipe/database/BasicDAO.java b/app/src/main/java/org/schabi/newpipe/database/BasicDAO.java index bcb9ece10..dd526ecc8 100644 --- a/app/src/main/java/org/schabi/newpipe/database/BasicDAO.java +++ b/app/src/main/java/org/schabi/newpipe/database/BasicDAO.java @@ -14,13 +14,13 @@ import io.reactivex.Flowable; @Dao public interface BasicDAO { /* Inserts */ - @Insert(onConflict = OnConflictStrategy.FAIL) + @Insert(onConflict = OnConflictStrategy.ABORT) long insert(Entity entity); - @Insert(onConflict = OnConflictStrategy.FAIL) + @Insert(onConflict = OnConflictStrategy.ABORT) List insertAll(Entity... entities); - @Insert(onConflict = OnConflictStrategy.FAIL) + @Insert(onConflict = OnConflictStrategy.ABORT) List insertAll(Collection entities); /* Searches */ diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java b/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java index bc160d873..979f8be75 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java @@ -1,6 +1,5 @@ package org.schabi.newpipe.download; -import android.app.FragmentTransaction; import android.content.Intent; import android.os.Bundle; import android.view.Menu; @@ -11,6 +10,7 @@ import android.view.ViewTreeObserver; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; +import androidx.fragment.app.FragmentTransaction; import org.schabi.newpipe.R; import org.schabi.newpipe.util.DeviceUtils; diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/TabAdaptor.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/TabAdaptor.java index 74609777c..c03f79dff 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/TabAdaptor.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/TabAdaptor.java @@ -16,7 +16,7 @@ public class TabAdaptor extends FragmentPagerAdapter { private final FragmentManager fragmentManager; public TabAdaptor(final FragmentManager fm) { - super(fm); + super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT); this.fragmentManager = fm; } 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 8018e2cd8..915bc3ec0 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 @@ -30,7 +30,7 @@ import android.view.View import android.view.ViewGroup import androidx.appcompat.app.AlertDialog import androidx.lifecycle.Observer -import androidx.lifecycle.ViewModelProviders +import androidx.lifecycle.ViewModelProvider import androidx.preference.PreferenceManager import icepick.State import java.util.Calendar @@ -82,7 +82,7 @@ class FeedFragment : BaseListFragment() { override fun onViewCreated(rootView: View, savedInstanceState: Bundle?) { super.onViewCreated(rootView, savedInstanceState) - viewModel = ViewModelProviders.of(this, FeedViewModel.Factory(requireContext(), groupId)).get(FeedViewModel::class.java) + viewModel = ViewModelProvider(this, FeedViewModel.Factory(requireContext(), groupId)).get(FeedViewModel::class.java) viewModel.stateLiveData.observe(viewLifecycleOwner, Observer { it?.let(::handleResult) }) } diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt index 7ebfec50e..b0d0fe801 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionFragment.kt @@ -17,7 +17,7 @@ import android.view.MenuInflater import android.view.View import android.view.ViewGroup import android.widget.Toast -import androidx.lifecycle.ViewModelProviders +import androidx.lifecycle.ViewModelProvider import androidx.localbroadcastmanager.content.LocalBroadcastManager import androidx.preference.PreferenceManager import androidx.recyclerview.widget.GridLayoutManager @@ -277,7 +277,7 @@ class SubscriptionFragment : BaseStateFragment() { } items_list.adapter = groupAdapter - viewModel = ViewModelProviders.of(this).get(SubscriptionViewModel::class.java) + viewModel = ViewModelProvider(this).get(SubscriptionViewModel::class.java) viewModel.stateLiveData.observe(viewLifecycleOwner, androidx.lifecycle.Observer { it?.let(this::handleResult) }) viewModel.feedGroupsLiveData.observe(viewLifecycleOwner, androidx.lifecycle.Observer { it?.let(this::handleFeedGroups) }) } diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupReorderDialog.kt b/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupReorderDialog.kt index 92c063b4b..48f40e219 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupReorderDialog.kt +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/dialog/FeedGroupReorderDialog.kt @@ -6,7 +6,7 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.DialogFragment import androidx.lifecycle.Observer -import androidx.lifecycle.ViewModelProviders +import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper.SimpleCallback import androidx.recyclerview.widget.LinearLayoutManager @@ -49,7 +49,7 @@ class FeedGroupReorderDialog : DialogFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - viewModel = ViewModelProviders.of(this).get(FeedGroupReorderDialogViewModel::class.java) + viewModel = ViewModelProvider(this).get(FeedGroupReorderDialogViewModel::class.java) viewModel.groupsLiveData.observe(viewLifecycleOwner, Observer(::handleGroups)) viewModel.dialogEventLiveData.observe(viewLifecycleOwner, Observer { when (it) { diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java index 57e5d1a27..587d414a9 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java @@ -30,6 +30,7 @@ import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.os.Build; import android.os.Handler; import androidx.preference.PreferenceManager; @@ -210,18 +211,18 @@ public abstract class VideoPlayer extends BasePlayer this.captionTextView = view.findViewById(R.id.captionTextView); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - playbackSeekBar.getThumb().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN); - } - this.playbackSeekBar.getProgressDrawable(). - setColorFilter(Color.RED, PorterDuff.Mode.MULTIPLY); + playbackSeekBar.getThumb() + .setColorFilter(new PorterDuffColorFilter(Color.RED, PorterDuff.Mode.SRC_IN)); + this.playbackSeekBar.getProgressDrawable() + .setColorFilter(new PorterDuffColorFilter(Color.RED, PorterDuff.Mode.MULTIPLY)); this.qualityPopupMenu = new PopupMenu(context, qualityTextView); this.playbackSpeedPopupMenu = new PopupMenu(context, playbackSpeedTextView); this.captionPopupMenu = new PopupMenu(context, captionTextView); ((ProgressBar) this.loadingPanel.findViewById(R.id.progressBarLoadingPanel)) - .getIndeterminateDrawable().setColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY); + .getIndeterminateDrawable() + .setColorFilter(new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY)); } protected abstract void setupSubtitleView(@NonNull SubtitleView view, float captionScale, @@ -456,11 +457,8 @@ public abstract class VideoPlayer extends BasePlayer animateView(controlsRoot, false, DEFAULT_CONTROLS_DURATION); playbackSeekBar.setEnabled(false); - // Bug on lower api, disabling and enabling the seekBar resets the thumb color -.-, - // so sets the color again - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - playbackSeekBar.getThumb().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN); - } + playbackSeekBar.getThumb() + .setColorFilter(new PorterDuffColorFilter(Color.RED, PorterDuff.Mode.SRC_IN)); loadingPanel.setBackgroundColor(Color.BLACK); animateView(loadingPanel, true, 0); @@ -476,11 +474,8 @@ public abstract class VideoPlayer extends BasePlayer showAndAnimateControl(-1, true); playbackSeekBar.setEnabled(true); - // Bug on lower api, disabling and enabling the seekBar resets the thumb color -.-, - // so sets the color again - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - playbackSeekBar.getThumb().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN); - } + playbackSeekBar.getThumb() + .setColorFilter(new PorterDuffColorFilter(Color.RED, PorterDuff.Mode.SRC_IN)); loadingPanel.setVisibility(View.GONE);