1
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-11-21 22:10:11 +01:00

Update Kotlin to 2.0, update dependencies and fix issues

This commit is contained in:
Isira Seneviratne 2024-07-28 08:12:19 +05:30
parent eaac7f3f85
commit e955beeef1
8 changed files with 21 additions and 34 deletions

View File

@ -9,6 +9,7 @@ plugins {
id "kotlin-parcelize" id "kotlin-parcelize"
id "checkstyle" id "checkstyle"
id "org.sonarqube" version "4.0.0.2929" id "org.sonarqube" version "4.0.0.2929"
id "org.jetbrains.kotlin.plugin.compose" version "${kotlin_version}"
} }
android { android {
@ -104,10 +105,6 @@ android {
'META-INF/COPYRIGHT'] 'META-INF/COPYRIGHT']
} }
} }
composeOptions {
kotlinCompilerExtensionVersion = "1.5.14"
}
} }
ext { ext {
@ -290,13 +287,13 @@ dependencies {
// Jetpack Compose // Jetpack Compose
implementation(platform('androidx.compose:compose-bom:2024.06.00')) implementation(platform('androidx.compose:compose-bom:2024.06.00'))
implementation 'androidx.compose.material3:material3:1.3.0-beta04' implementation 'androidx.compose.material3:material3:1.3.0-beta05'
implementation 'androidx.activity:activity-compose' implementation 'androidx.activity:activity-compose'
implementation 'androidx.compose.ui:ui-tooling-preview' implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.ui:ui-text:1.7.0-beta04' // Needed for parsing HTML to AnnotatedString implementation 'androidx.compose.ui:ui-text:1.7.0-beta06' // Needed for parsing HTML to AnnotatedString
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose' implementation 'androidx.lifecycle:lifecycle-viewmodel-compose'
implementation 'androidx.paging:paging-compose:3.3.0' implementation 'androidx.paging:paging-compose:3.3.1'
implementation 'com.github.nanihadesuka:LazyColumnScrollbar:2.1.0' implementation 'com.github.nanihadesuka:LazyColumnScrollbar:2.2.0'
/** Debugging **/ /** Debugging **/
// Memory leak detection // Memory leak detection

View File

@ -185,10 +185,8 @@ public class ReCaptchaActivity extends AppCompatActivity {
final int abuseEnd = url.indexOf("+path"); final int abuseEnd = url.indexOf("+path");
try { try {
String abuseCookie = url.substring(abuseStart + 13, abuseEnd); handleCookies(Utils.decodeUrlUtf8(url.substring(abuseStart + 13, abuseEnd)));
abuseCookie = Utils.decodeUrlUtf8(abuseCookie); } catch (final StringIndexOutOfBoundsException e) {
handleCookies(abuseCookie);
} catch (IllegalArgumentException | StringIndexOutOfBoundsException e) {
if (MainActivity.DEBUG) { if (MainActivity.DEBUG) {
Log.e(TAG, "handleCookiesFromUrl: invalid google abuse starting at " Log.e(TAG, "handleCookiesFromUrl: invalid google abuse starting at "
+ abuseStart + " and ending at " + abuseEnd + " for url " + url, e); + abuseStart + " and ending at " + abuseEnd + " for url " + url, e);

View File

@ -202,6 +202,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
// Menu // Menu
// ///////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////
@Deprecated("Deprecated in Java")
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater) super.onCreateOptionsMenu(menu, inflater)
@ -212,6 +213,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
inflater.inflate(R.menu.menu_feed_fragment, menu) inflater.inflate(R.menu.menu_feed_fragment, menu)
} }
@Deprecated("Deprecated in Java")
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.menu_item_feed_help) { if (item.itemId == R.id.menu_item_feed_help) {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext()) val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
@ -253,7 +255,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
viewModel.getShowFutureItemsFromPreferences() viewModel.getShowFutureItemsFromPreferences()
) )
AlertDialog.Builder(context!!) AlertDialog.Builder(requireContext())
.setTitle(R.string.feed_hide_streams_title) .setTitle(R.string.feed_hide_streams_title)
.setMultiChoiceItems(dialogItems, checkedDialogItems) { _, which, isChecked -> .setMultiChoiceItems(dialogItems, checkedDialogItems) { _, which, isChecked ->
checkedDialogItems[which] = isChecked checkedDialogItems[which] = isChecked
@ -267,6 +269,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
.show() .show()
} }
@Deprecated("Deprecated in Java")
override fun onDestroyOptionsMenu() { override fun onDestroyOptionsMenu() {
super.onDestroyOptionsMenu() super.onDestroyOptionsMenu()
activity?.supportActionBar?.subtitle = null activity?.supportActionBar?.subtitle = null

View File

@ -129,6 +129,7 @@ class SubscriptionFragment : BaseStateFragment<SubscriptionState>() {
// Menu // Menu
// //////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////////
@Deprecated("Deprecated in Java")
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater) super.onCreateOptionsMenu(menu, inflater)

View File

@ -94,6 +94,7 @@ class FeedGroupDialog : DialogFragment(), BackPressable {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return object : Dialog(requireActivity(), theme) { return object : Dialog(requireActivity(), theme) {
@Deprecated("Deprecated in Java")
override fun onBackPressed() { override fun onBackPressed() {
if (!this@FeedGroupDialog.onBackPressed()) { if (!this@FeedGroupDialog.onBackPressed()) {
super.onBackPressed() super.onBackPressed()

View File

@ -1,6 +1,5 @@
package org.schabi.newpipe.settings; package org.schabi.newpipe.settings;
import static org.schabi.newpipe.extractor.utils.Utils.decodeUrlUtf8;
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage; import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
import android.app.Activity; import android.app.Activity;
@ -30,7 +29,6 @@ import org.schabi.newpipe.util.FilePickerActivityHelper;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URI;
public class DownloadSettingsFragment extends BasePreferenceFragment { public class DownloadSettingsFragment extends BasePreferenceFragment {
public static final boolean IGNORE_RELEASE_ON_OLD_PATH = true; public static final boolean IGNORE_RELEASE_ON_OLD_PATH = true;
@ -107,28 +105,15 @@ public class DownloadSettingsFragment extends BasePreferenceFragment {
private void showPathInSummary(final String prefKey, @StringRes final int defaultString, private void showPathInSummary(final String prefKey, @StringRes final int defaultString,
final Preference target) { final Preference target) {
String rawUri = defaultPreferences.getString(prefKey, null); final Uri uri = Uri.parse(defaultPreferences.getString(prefKey, ""));
if (rawUri == null || rawUri.isEmpty()) { if (uri.equals(Uri.EMPTY)) {
target.setSummary(getString(defaultString)); target.setSummary(getString(defaultString));
return; return;
} }
if (rawUri.charAt(0) == File.separatorChar) { final String summary = ContentResolver.SCHEME_FILE.equals(uri.getScheme())
target.setSummary(rawUri); ? uri.getPath() : uri.toString();
return; target.setSummary(summary);
}
if (rawUri.startsWith(ContentResolver.SCHEME_FILE)) {
target.setSummary(new File(URI.create(rawUri)).getPath());
return;
}
try {
rawUri = decodeUrlUtf8(rawUri);
} catch (final IllegalArgumentException e) {
// nothing to do
}
target.setSummary(rawUri);
} }
private boolean isFileUri(final String path) { private boolean isFileUri(final String path) {

View File

@ -77,11 +77,13 @@ class NotificationModeConfigFragment : Fragment() {
super.onDestroy() super.onDestroy()
} }
@Deprecated("Deprecated in Java")
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater) super.onCreateOptionsMenu(menu, inflater)
inflater.inflate(R.menu.menu_notifications_channels, menu) inflater.inflate(R.menu.menu_notifications_channels, menu)
} }
@Deprecated("Deprecated in Java")
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) { return when (item.itemId) {
R.id.action_toggle_all -> { R.id.action_toggle_all -> {

View File

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.9.24' ext.kotlin_version = '2.0.0'
repositories { repositories {
google() google()
mavenCentral() mavenCentral()