Skip to content

Commit

Permalink
app target SDK 34
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Apr 19, 2024
1 parent f381c57 commit a5a1296
Show file tree
Hide file tree
Showing 13 changed files with 459 additions and 606 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
This project is a full conversion of [NewPipe](https://github.com/TeamNewPipe/NewPipe) (cloned as of Feb 5 2024) to Kotlin. Most existing dependencies are updated. Built SDK is 34 and target SDK is 33. Code and null safety issues are resolved after the conversion. Other than that, there is no logic or structural change from the original project.
This project is a full conversion of [NewPipe](https://github.com/TeamNewPipe/NewPipe) (cloned as of Feb 5 2024) to Kotlin. Most existing dependencies are updated. ~Built SDK is 34 and target SDK is 33.~ Code and null safety issues are resolved after the conversion. ~Other than that, there is no logic or structural change from the original project.~

Introductory migration to androidx.media3 and removal of exoplayer2. Though not having been thoroughly tested, things appear to work.

Built SDK is 34 and target SDK is 34

For non-intrusive testing, the appId and name is changed to NewPipeX.

See more changes and issues in [changelog](changelog.md)
Expand Down
7 changes: 4 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ android {
applicationId "org.schabi.newpipex"
resValue "string", "app_name", "NewPipeX"
minSdk 24
targetSdk 33
versionCode 998
versionName "0.26.3"
//noinspection EditedTargetSdkVersion
targetSdk 34
versionCode 999
versionName "0.26.4"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ abstract class FragmentStatePagerAdapterMenuWorkaround
) : PagerAdapter() {
@Retention(AnnotationRetention.SOURCE)
@IntDef(Behavior.BEHAVIOR_SET_USER_VISIBLE_HINT, Behavior.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT)

protected annotation class Behavior {
companion object {
const val BEHAVIOR_SET_USER_VISIBLE_HINT = 0
Expand Down Expand Up @@ -96,7 +97,7 @@ abstract class FragmentStatePagerAdapterMenuWorkaround
*/
@Deprecated("""use {@link #FragmentStatePagerAdapterMenuWorkaround(FragmentManager, int)} with
{@link #BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT}""")
constructor(fm: FragmentManager) : this(fm, BEHAVIOR_SET_USER_VISIBLE_HINT)
constructor(fm: FragmentManager) : this(fm, Behavior.BEHAVIOR_SET_USER_VISIBLE_HINT)

/**
* @param position the position of the item you want
Expand Down Expand Up @@ -142,14 +143,14 @@ abstract class FragmentStatePagerAdapterMenuWorkaround
mFragments.add(null)
}
fragment.setMenuVisibility(false)
if (mBehavior == BEHAVIOR_SET_USER_VISIBLE_HINT) {
if (mBehavior == Behavior.BEHAVIOR_SET_USER_VISIBLE_HINT) {
fragment.userVisibleHint = false
}

mFragments[position] = fragment
mCurTransaction!!.add(container.id, fragment)

if (mBehavior == BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
if (mBehavior == Behavior.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
mCurTransaction!!.setMaxLifecycle(fragment, Lifecycle.State.STARTED)
}

Expand Down Expand Up @@ -189,7 +190,7 @@ abstract class FragmentStatePagerAdapterMenuWorkaround
if (fragment !== mCurrentPrimaryItem) {
if (mCurrentPrimaryItem != null) {
mCurrentPrimaryItem!!.setMenuVisibility(false)
if (mBehavior == BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
if (mBehavior == Behavior.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
if (mCurTransaction == null) {
mCurTransaction = mFragmentManager.beginTransaction()
}
Expand All @@ -199,7 +200,7 @@ abstract class FragmentStatePagerAdapterMenuWorkaround
}
}
fragment.setMenuVisibility(true)
if (mBehavior == BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
if (mBehavior == Behavior.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
if (mCurTransaction == null) {
mCurTransaction = mFragmentManager.beginTransaction()
}
Expand Down Expand Up @@ -309,19 +310,19 @@ abstract class FragmentStatePagerAdapterMenuWorkaround
*
* @see .FragmentStatePagerAdapterMenuWorkaround
*/
@Deprecated("""This behavior relies on the deprecated
{@link Fragment#setUserVisibleHint(boolean)} API. Use
{@link #BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT} to switch to its replacement,
{@link FragmentTransaction#setMaxLifecycle}.
""")
const val BEHAVIOR_SET_USER_VISIBLE_HINT: Int = 0
// @Deprecated("""This behavior relies on the deprecated
// {@link Fragment#setUserVisibleHint(boolean)} API. Use
// {@link #BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT} to switch to its replacement,
// {@link FragmentTransaction#setMaxLifecycle}.
// """)
// const val BEHAVIOR_SET_USER_VISIBLE_HINT: Int = 0

/**
* Indicates that only the current fragment will be in the [Lifecycle.State.RESUMED]
* state. All other Fragments are capped at [Lifecycle.State.STARTED].
*
* @see .FragmentStatePagerAdapterMenuWorkaround
*/
const val BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT: Int = 1
// const val BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT: Int = 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import android.util.Log
import android.view.*
import android.widget.RelativeLayout
import androidx.annotation.ColorInt
import androidx.annotation.OptIn
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapterMenuWorkaround
import androidx.media3.common.util.UnstableApi
import androidx.preference.PreferenceManager
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayout.OnTabSelectedListener
Expand Down Expand Up @@ -137,7 +139,7 @@ class MainFragment : BaseFragment(), OnTabSelectedListener {
supportActionBar?.setDisplayHomeAsUpEnabled(false)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
@OptIn(UnstableApi::class) override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.action_search) {
try {
openSearchFragment(fM!!, getSelectedServiceId(requireActivity()), "")
Expand Down Expand Up @@ -235,9 +237,7 @@ class MainFragment : BaseFragment(), OnTabSelectedListener {
updateTitleForTab(tab.position)
}

class SelectedTabsPagerAdapter(private val context: Context,
fragmentManager: FragmentManager,
tabsList: List<Tab>)
class SelectedTabsPagerAdapter(private val context: Context, fragmentManager: FragmentManager, tabsList: List<Tab>)
: FragmentStatePagerAdapterMenuWorkaround(fragmentManager, Behavior.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {

private val internalTabsList: List<Tab> = ArrayList(tabsList)
Expand Down
Loading

0 comments on commit a5a1296

Please sign in to comment.