major migration part 2
- Commit
cd8f3a609cbc09a3184cfa6eeb5c54c7f4a49c11- Author
- Vayun Mathur <[email protected]>
- When
- 2026-07-31 19:25 UTC (4 months ago)
- Parents
194e910
Diff
appstore/src/main/java/com/vayunmathur/appstore/data/installer/PlayDownloader.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/PlayDownloader.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/PlayDownloader.ktindex 161d73d318..51f969e042 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/PlayDownloader.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/PlayDownloader.kt@@ -3,26 +3,19 @@ package com.vayunmathur.appstore.data.installer import android.content.Context import android.util.Log import com.aurora.gplayapi.data.models.PlayFile-import okhttp3.OkHttpClient-import okhttp3.Request import java.io.File-import java.util.concurrent.TimeUnit+import java.net.HttpURLConnection+import java.net.URL /** * Downloads Play Store split APKs with resume + SHA verification,- * then delegates to SessionInstaller.+ * then delegates to SessionInstaller — now using HttpURLConnection. */ class PlayDownloader(- private val context: Context,- private val okHttpClient: OkHttpClient = defaultClient()+ private val context: Context ) { companion object { private const val TAG = "PlayDownloader"- private fun defaultClient() = OkHttpClient.Builder()- .connectTimeout(30, TimeUnit.SECONDS)- .readTimeout(60, TimeUnit.SECONDS)- .writeTimeout(30, TimeUnit.SECONDS)- .build() } class ExpiredUrlException(message: String) : Exception(message)@@ -47,7 +40,6 @@ class PlayDownloader( val destFile = File(baseDir, fileName) val tmpFile = File(baseDir, "$fileName.tmp") - // Skip if already exists and size matches if (destFile.exists() && destFile.length() > 0) { if (gFile.size <= 0 || destFile.length() == gFile.size) { localFiles.add(destFile)@@ -70,8 +62,6 @@ class PlayDownloader( } val file = result.getOrNull()!!- // Lenient verification for V1 – hashes present but format may vary- // We skip strict blocking; just log mismatch localFiles.add(file) totalDownloaded += file.length() }@@ -90,27 +80,39 @@ class PlayDownloader( progressCallback: (Long) -> Unit ): Result<File> { return try {- val url = gFile.url.takeIf { it.isNotBlank() } ?: return Result.failure(Exception("Empty URL for ${gFile.name}"))-+ val urlString = gFile.url.takeIf { it.isNotBlank() } ?: return Result.failure(Exception("Empty URL for ${gFile.name}")) val existing = if (tmpFile.exists()) tmpFile.length() else 0L- val requestBuilder = Request.Builder().url(url)- if (existing > 0) {- requestBuilder.addHeader("Range", "bytes=$existing-")++ val conn = (URL(urlString).openConnection() as HttpURLConnection).apply {+ connectTimeout = 30_000+ readTimeout = 60_000+ instanceFollowRedirects = true+ useCaches = false+ if (existing > 0) {+ setRequestProperty("Range", "bytes=$existing-")+ } }- val request = requestBuilder.build()- val response = okHttpClient.newCall(request).execute() - if (!response.isSuccessful && response.code != 206) {- if (response.code == 403 || response.code == 410) {- return Result.failure(ExpiredUrlException("URL expired ${response.code}"))+ val code = try { conn.responseCode } catch (e: Exception) {+ conn.disconnect()+ throw e+ }++ if (code !in 200..299 && code != 206) {+ conn.disconnect()+ if (code == 403 || code == 410) {+ return Result.failure(ExpiredUrlException("URL expired $code")) }- return Result.failure(Exception("HTTP ${response.code}"))+ return Result.failure(Exception("HTTP $code")) } - val body = response.body ?: return Result.failure(Exception("Empty body"))- val input = body.byteStream()+ val input = try {+ conn.inputStream+ } catch (_: Exception) {+ conn.disconnect()+ return Result.failure(Exception("Empty body"))+ } - // Use append if resuming val output = if (existing > 0) { java.io.FileOutputStream(tmpFile, true) } else {@@ -118,16 +120,20 @@ class PlayDownloader( } var downloaded = existing- output.use { out ->- input.use { inp ->- val buffer = ByteArray(8192)- var read: Int- while (inp.read(buffer).also { read = it } != -1) {- out.write(buffer, 0, read)- downloaded += read- progressCallback(downloaded)+ try {+ output.use { out ->+ input.use { inp ->+ val buffer = ByteArray(8192)+ var read: Int+ while (inp.read(buffer).also { read = it } != -1) {+ out.write(buffer, 0, read)+ downloaded += read+ progressCallback(downloaded)+ } } }+ } finally {+ conn.disconnect() } if (tmpFile.exists()) {
appstore/src/main/java/com/vayunmathur/appstore/data/play/AnonymousAuthRepository.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/play/AnonymousAuthRepository.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/play/AnonymousAuthRepository.ktindex 4751395deb..d9556ff9cc 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/play/AnonymousAuthRepository.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/play/AnonymousAuthRepository.kt@@ -9,20 +9,15 @@ import kotlinx.coroutines.withContext import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json-import okhttp3.MediaType.Companion.toMediaTypeOrNull-import okhttp3.OkHttpClient-import okhttp3.Request-import okhttp3.RequestBody.Companion.toRequestBody+import java.net.HttpURLConnection+import java.net.URL import java.util.Properties-import java.util.concurrent.TimeUnit /**- * Anonymous auth via Aurora dispenser.- * Ported from AuroraStore's AuthProvider.+ * Anonymous auth via Aurora dispenser — now using HttpURLConnection.+ * Ported from AuroraStore's AuthProvider; previously used OkHttp. */-class AnonymousAuthRepository(- private val okHttpClient: OkHttpClient = defaultClient()-) {+class AnonymousAuthRepository { companion object { private const val TAG = "AnonAuthRepo"@@ -31,12 +26,6 @@ class AnonymousAuthRepository( "https://auroraoss.com/api/auth" ) - private fun defaultClient() = OkHttpClient.Builder()- .connectTimeout(15, TimeUnit.SECONDS)- .readTimeout(15, TimeUnit.SECONDS)- .writeTimeout(15, TimeUnit.SECONDS)- .build()- private val json = Json { ignoreUnknownKeys = true } } @@ -76,20 +65,35 @@ class AnonymousAuthRepository( } catch (_: Exception) { "1" } val userAgent = "$appId-$versionName-$versionCode"- val body = propsJson.toRequestBody("application/json".toMediaTypeOrNull())-- val request = Request.Builder()- .url(dispenserUrl)- .header("User-Agent", userAgent)- .header("Content-Type", "application/json")- .post(body)- .build()+ val bodyBytes = propsJson.toByteArray(Charsets.UTF_8)++ val conn = (URL(dispenserUrl).openConnection() as HttpURLConnection).apply {+ connectTimeout = 15_000+ readTimeout = 15_000+ requestMethod = "POST"+ doOutput = true+ doInput = true+ instanceFollowRedirects = false+ useCaches = false+ setRequestProperty("User-Agent", userAgent)+ setRequestProperty("Content-Type", "application/json")+ setFixedLengthStreamingMode(bodyBytes.size)+ }+ conn.outputStream.use { it.write(bodyBytes) } - val response = okHttpClient.newCall(request).execute()- val responseBody = response.body?.string() ?: ""+ val code = try { conn.responseCode } catch (e: Exception) {+ conn.disconnect()+ return@withContext Result.failure(AuthError.Network(e.message))+ }+ val responseBody = try {+ val stream = if (code >= 400) conn.errorStream ?: conn.inputStream else conn.inputStream+ stream?.bufferedReader(Charsets.UTF_8)?.readText() ?: ""+ } catch (_: Exception) { "" } finally {+ conn.disconnect()+ } - if (!response.isSuccessful) {- return@withContext Result.failure(mapError(response.code, responseBody))+ if (code !in 200..299) {+ return@withContext Result.failure(mapError(code, responseBody)) } try {@@ -97,7 +101,7 @@ class AnonymousAuthRepository( Result.success(auth) } catch (e: Exception) { Log.w(TAG, "Parse auth failed: ${e.message}")- Result.failure(AuthError.Unknown(response.code, responseBody))+ Result.failure(AuthError.Unknown(code, responseBody)) } } catch (e: Exception) { Result.failure(AuthError.Network(e.message))@@ -106,7 +110,6 @@ class AnonymousAuthRepository( /** * Build AuthData from dispenser response using gplayapi AuthHelper.- * AuthHelper.build(email, token, Token.AUTH, isAnonymous=true, properties, locale) */ suspend fun buildAuthData( context: Context,
contacts/build.gradle.kts
diff --git a/contacts/build.gradle.kts b/contacts/build.gradle.ktsindex a454ec38e4..8df3e006bf 100644--- a/contacts/build.gradle.kts+++ b/contacts/build.gradle.kts@@ -23,9 +23,7 @@ metadataScreenshots { } dependencies {-- // External Libraries- implementation(libs.okio) // isolated: VCF export/import, FileSystem – not networking+ // VCF export/import now uses java.io BufferedReader/Writer – no okio needed implementation(libs.libphonenumber) implementation(libs.androidx.work.runtime.ktx) }
contacts/src/main/java/com/vayunmathur/contacts/ui/ContactDetailsPage.kt
diff --git a/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactDetailsPage.kt b/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactDetailsPage.ktindex 43128b8791..4668063abd 100644--- a/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactDetailsPage.kt+++ b/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactDetailsPage.kt@@ -99,9 +99,6 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import kotlinx.datetime.LocalDate import kotlinx.datetime.format-import okio.FileSystem-import okio.Path.Companion.toOkioPath-import okio.buffer @OptIn(ExperimentalMaterial3Api::class) @Composable
contacts/src/main/java/com/vayunmathur/contacts/ui/ContactList.kt
diff --git a/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactList.kt b/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactList.ktindex 6a37dc42e9..1e0422b454 100644--- a/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactList.kt+++ b/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactList.kt@@ -78,9 +78,6 @@ import com.vayunmathur.library.ui.IconClose import com.vayunmathur.library.ui.CommonSearchBar import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.launch-import okio.FileSystem-import okio.Path.Companion.toOkioPath-import okio.buffer import android.content.Intent import androidx.compose.ui.platform.LocalResources
contacts/src/main/java/com/vayunmathur/contacts/ui/ContactUiHelpers.kt
diff --git a/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactUiHelpers.kt b/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactUiHelpers.ktindex abccd776f3..f861365712 100644--- a/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactUiHelpers.kt+++ b/contacts/src/main/java/com/vayunmathur/contacts/ui/ContactUiHelpers.kt@@ -31,9 +31,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext-import okio.FileSystem-import okio.Path.Companion.toOkioPath-import okio.buffer+import java.io.File /** Display name with optional nickname suffix (e.g. "Jane Doe (Janey)"). */ @Composable@@ -57,7 +55,7 @@ fun ContactAvatar( initialsStyle: TextStyle = MaterialTheme.typography.bodyLarge, ) { val photoBase64 = contact.photo?.photo- val avatarBitmap by produceState<Bitmap?>(null, photoBase64, viewModel) {+ val avatarBitmap by produceState<Bitmap?>(initialValue = null, key1 = photoBase64, key2 = viewModel) { value = if (photoBase64 != null) { withContext(Dispatchers.IO) { viewModel?.decodePhoto(photoBase64) } } else null@@ -95,9 +93,9 @@ fun shareContactsAsVcf( chooserTitle: String, ) { scope.launch(Dispatchers.IO) {- val vcfFile = context.cacheDir.toOkioPath().resolve(filename)- FileSystem.SYSTEM.sink(vcfFile).buffer().use { VcfUtils.exportContacts(contacts, it) }- val uri = FileProvider.getUriForFile(context, "${context.packageName}.provider", vcfFile.toFile())+ val vcfFile = File(context.cacheDir, filename)+ vcfFile.outputStream().use { out -> VcfUtils.exportContacts(contacts, out) }+ val uri = FileProvider.getUriForFile(context, "${context.packageName}.provider", vcfFile) val intent = Intent(Intent.ACTION_SEND).apply { type = "text/x-vcard" putExtra(Intent.EXTRA_STREAM, uri)
contacts/src/main/java/com/vayunmathur/contacts/ui/EditContactPage.kt
diff --git a/contacts/src/main/java/com/vayunmathur/contacts/ui/EditContactPage.kt b/contacts/src/main/java/com/vayunmathur/contacts/ui/EditContactPage.ktindex 44ab238aa5..7f97e7243d 100644--- a/contacts/src/main/java/com/vayunmathur/contacts/ui/EditContactPage.kt+++ b/contacts/src/main/java/com/vayunmathur/contacts/ui/EditContactPage.kt@@ -91,7 +91,6 @@ import com.vayunmathur.library.ui.IconRemoveCircle import com.vayunmathur.library.util.NavBackStack import com.vayunmathur.library.util.ResultEffect import kotlinx.datetime.LocalDate-import okio.Buffer import kotlin.io.encoding.Base64 @OptIn(ExperimentalMaterial3Api::class)
contacts/src/main/java/com/vayunmathur/contacts/ui/ImportActivity.kt
diff --git a/contacts/src/main/java/com/vayunmathur/contacts/ui/ImportActivity.kt b/contacts/src/main/java/com/vayunmathur/contacts/ui/ImportActivity.ktindex e45d198077..1afc68853f 100644--- a/contacts/src/main/java/com/vayunmathur/contacts/ui/ImportActivity.kt+++ b/contacts/src/main/java/com/vayunmathur/contacts/ui/ImportActivity.kt@@ -25,7 +25,6 @@ import com.vayunmathur.contacts.MainActivity import com.vayunmathur.contacts.data.ContactDetails import com.vayunmathur.library.ui.DynamicTheme import com.vayunmathur.library.ui.IconSave-import okio.source import com.vayunmathur.contacts.data.Contact import com.vayunmathur.contacts.util.VcfUtils import com.vayunmathur.contacts.R@@ -36,8 +35,8 @@ class ImportActivity : ComponentActivity() { val uri = intent.data ?: return - val contacts = contentResolver.openInputStream(uri)?.source()?.use { stream ->- VcfUtils.parseContacts(stream)+ val contacts = contentResolver.openInputStream(uri)?.use { input ->+ VcfUtils.parseContacts(input) } ?: emptyList() setContent {
contacts/src/main/java/com/vayunmathur/contacts/ui/SettingsPage.kt
diff --git a/contacts/src/main/java/com/vayunmathur/contacts/ui/SettingsPage.kt b/contacts/src/main/java/com/vayunmathur/contacts/ui/SettingsPage.ktindex efc088e3f1..7956c6c912 100644--- a/contacts/src/main/java/com/vayunmathur/contacts/ui/SettingsPage.kt+++ b/contacts/src/main/java/com/vayunmathur/contacts/ui/SettingsPage.kt@@ -30,7 +30,6 @@ import com.vayunmathur.library.ui.IconAdd import com.vayunmathur.library.ui.IconNavigation import com.vayunmathur.library.util.NavBackStack import kotlinx.coroutines.launch-import okio.sink @OptIn(ExperimentalMaterial3Api::class) @Composable@@ -58,7 +57,7 @@ fun SettingsPage(viewModel: ContactViewModel, backStack: NavBackStack<Route>) { uri?.let { coroutineScope.launch { try {- context.contentResolver.openOutputStream(it)?.sink()?.use { outputStream ->+ context.contentResolver.openOutputStream(it)?.use { outputStream -> VcfUtils.exportContacts(contacts, outputStream) } } catch (e: Exception) {
contacts/src/main/java/com/vayunmathur/contacts/util/ContactViewModel.kt
diff --git a/contacts/src/main/java/com/vayunmathur/contacts/util/ContactViewModel.kt b/contacts/src/main/java/com/vayunmathur/contacts/util/ContactViewModel.ktindex 0212aaea49..a7964865d8 100644--- a/contacts/src/main/java/com/vayunmathur/contacts/util/ContactViewModel.kt+++ b/contacts/src/main/java/com/vayunmathur/contacts/util/ContactViewModel.kt@@ -30,7 +30,6 @@ import com.vayunmathur.contacts.data.PhoneNumber import com.vayunmathur.contacts.data.Photo import com.vayunmathur.library.util.DataStoreUtils import kotlinx.coroutines.Dispatchers-import okio.source import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow@@ -305,8 +304,8 @@ class ContactViewModel(application: Application) : AndroidViewModel(application) val allContacts = mutableListOf<Contact>() uris.forEach { uri -> try {- app.contentResolver.openInputStream(uri)?.source()?.use { source ->- allContacts.addAll(VcfUtils.parseContacts(source))+ app.contentResolver.openInputStream(uri)?.use { input ->+ allContacts.addAll(VcfUtils.parseContacts(input)) } } catch (e: Exception) { android.util.Log.e("ContactViewModel", "Error parsing VCF file: $uri", e)@@ -623,9 +622,9 @@ class ContactViewModel(application: Application) : AndroidViewModel(application) val scaled = if (bitmap.width != 1024 || bitmap.height != 1024) { Bitmap.createScaledBitmap(bitmap, 1024, 1024, true) } else bitmap- val baos = okio.Buffer()- scaled.compress(Bitmap.CompressFormat.JPEG, 100, baos.outputStream())- val encoded = Base64.encode(baos.readByteArray())+ val baos = java.io.ByteArrayOutputStream()+ scaled.compress(Bitmap.CompressFormat.JPEG, 100, baos)+ val encoded = Base64.encode(baos.toByteArray()) updateEditDraft { draft -> val newPhoto = draft.photo?.withValue(encoded) ?: com.vayunmathur.contacts.data.Photo(0, encoded)
files/src/main/java/com/vayunmathur/files/util/FilesViewModel.kt
diff --git a/files/src/main/java/com/vayunmathur/files/util/FilesViewModel.kt b/files/src/main/java/com/vayunmathur/files/util/FilesViewModel.ktindex 3fa74a2214..fa0a7a6c87 100644--- a/files/src/main/java/com/vayunmathur/files/util/FilesViewModel.kt+++ b/files/src/main/java/com/vayunmathur/files/util/FilesViewModel.kt@@ -16,10 +16,6 @@ import androidx.work.OneTimeWorkRequestBuilder import androidx.work.WorkManager import androidx.work.workDataOf import com.vayunmathur.files.R-import com.vayunmathur.files.deleteRecursively-import com.vayunmathur.files.fs-import com.vayunmathur.files.isDirectory-import com.vayunmathur.files.listFiles import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.awaitCancellation@@ -30,12 +26,8 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch-import okio.FileSystem-import okio.Path-import okio.Path.Companion.toOkioPath-import okio.Path.Companion.toPath-import okio.openZip-import okio.source+import java.io.File+import java.util.zip.ZipFile class FilesViewModel(application: Application) : AndroidViewModel(application) { @@ -47,7 +39,6 @@ class FilesViewModel(application: Application) : AndroidViewModel(application) { private val _isFilesGranted = MutableStateFlow(Environment.isExternalStorageManager()) val isFilesGranted: StateFlow<Boolean> = _isFilesGranted.asStateFlow() - /** Re-checks the MANAGE_EXTERNAL_STORAGE permission (call from MainActivity onResume). */ fun refreshPermissions() { val granted = Environment.isExternalStorageManager() if (_isFilesGranted.value != granted) {@@ -67,42 +58,47 @@ class FilesViewModel(application: Application) : AndroidViewModel(application) { // ---- Navigation state ---- - /** Stable storage-root path used for "home" / back-handler base. */- val rootDirectory: Path = Environment.getExternalStorageDirectory().toOkioPath()-- private val _currentFileSystem = MutableStateFlow<FileSystem>(fs)- val currentFileSystem: StateFlow<FileSystem> = _currentFileSystem.asStateFlow()+ val rootDirectory: File = Environment.getExternalStorageDirectory() private val _currentDirectory = MutableStateFlow(rootDirectory)- val currentDirectory: StateFlow<Path> = _currentDirectory.asStateFlow()+ val currentDirectory: StateFlow<File> = _currentDirectory.asStateFlow()++ /** The on-disk zip file when browsing inside an opened archive; null otherwise. */+ private val _zipPath = MutableStateFlow<File?>(null)+ val zipPath: StateFlow<File?> = _zipPath.asStateFlow()++ /** Relative path inside the opened zip, "" = root. */+ private val _zipInternalPath = MutableStateFlow("")+ val zipInternalPath: StateFlow<String> = _zipInternalPath.asStateFlow() - /** The on-disk zip file when browsing inside an opened archive; `null` otherwise. */- private val _zipPath = MutableStateFlow<Path?>(null)- val zipPath: StateFlow<Path?> = _zipPath.asStateFlow()+ fun isZipMode(): Boolean = _zipPath.value != null // ---- Directory listing ---- - /** (directories, files) for [currentDirectory], partitioned & sorted on Dispatchers.IO. */ private val _entries =- MutableStateFlow<Pair<List<Path>, List<Path>>>(emptyList<Path>() to emptyList())- val entries: StateFlow<Pair<List<Path>, List<Path>>> = _entries.asStateFlow()+ MutableStateFlow<Pair<List<File>, List<File>>>(emptyList<File>() to emptyList())+ val entries: StateFlow<Pair<List<File>, List<File>>> = _entries.asStateFlow() // ---- Selection ---- - private val _selectedPaths = MutableStateFlow<Set<Path>>(emptySet())- val selectedPaths: StateFlow<Set<Path>> = _selectedPaths.asStateFlow()+ private val _selectedPaths = MutableStateFlow<Set<File>>(emptySet())+ val selectedPaths: StateFlow<Set<File>> = _selectedPaths.asStateFlow() fun clearSelection() { if (_selectedPaths.value.isNotEmpty()) _selectedPaths.value = emptySet() } - fun addToSelection(path: Path) {+ fun addToSelection(path: File) { _selectedPaths.value = _selectedPaths.value + path } - fun toggleSelection(path: Path) {+ fun toggleSelection(path: File) { val current = _selectedPaths.value- _selectedPaths.value = if (path in current) current - path else current + path+ _selectedPaths.value = if (current.any { it.absolutePath == path.absolutePath && it.name == path.name }) {+ current.filterNot { it.absolutePath == path.absolutePath && it.name == path.name }.toSet()+ } else {+ current + path+ } } // ---- Incoming share-intent URIs ----@@ -124,11 +120,8 @@ class FilesViewModel(application: Application) : AndroidViewModel(application) { val snackbarMessages: SharedFlow<String> = _snackbarMessages.asSharedFlow() private val _intents = MutableSharedFlow<Intent>(extraBufferCapacity = 4)- /** Emits ACTION_VIEW intents for files the user taps; MainActivity launches them. */ val intents: SharedFlow<Intent> = _intents.asSharedFlow() - // ---- FileObserver lifecycle ----- private var observerJob: Job? = null init {@@ -136,25 +129,32 @@ class FilesViewModel(application: Application) : AndroidViewModel(application) { restartObserver() } - /** Re-list the current directory off the main thread. */ fun loadDirectory() {- val dir = _currentDirectory.value- val fileSystem = _currentFileSystem.value- viewModelScope.launch(Dispatchers.IO) {- _entries.value = dir.listFiles(fileSystem).partition { it.isDirectory(fileSystem) }+ val zipFile = _zipPath.value+ if (zipFile == null) {+ val dir = _currentDirectory.value+ viewModelScope.launch(Dispatchers.IO) {+ val files = dir.listFiles()?.toList() ?: emptyList()+ _entries.value = files.partition { it.isDirectory }+ }+ } else {+ val internalPath = _zipInternalPath.value+ viewModelScope.launch(Dispatchers.IO) {+ _entries.value = listZipEntries(zipFile, internalPath)+ } } } private fun restartObserver() { observerJob?.cancel()- if (_currentFileSystem.value != fs) {+ if (isZipMode()) { observerJob = null return } val dir = _currentDirectory.value observerJob = viewModelScope.launch { val observer = object : FileObserver(- dir.toFile(), CREATE or DELETE or MOVED_FROM or MOVED_TO,+ dir, CREATE or DELETE or MOVED_FROM or MOVED_TO, ) { override fun onEvent(event: Int, path: String?) { loadDirectory()@@ -169,20 +169,34 @@ class FilesViewModel(application: Application) : AndroidViewModel(application) { } } - /** Navigate to [path] on [fileSystem]; clears selection and the open zip when leaving zip mode. */- fun navigateTo(path: Path, fileSystem: FileSystem) {- _currentFileSystem.value = fileSystem+ fun navigateTo(path: File) {+ if (isZipMode()) {+ // If navigating while in zip mode via breadcrumb real-FS part, exit zip mode+ _zipPath.value = null+ _zipInternalPath.value = ""+ } _currentDirectory.value = path- if (fileSystem == fs) _zipPath.value = null clearSelection() loadDirectory() restartObserver() } - /**- * Back-handler logic mirroring the original `BackHandler` body. Returns `true` if it consumed- * the event.- */+ /** Navigate into a sub-directory inside the opened zip. */+ fun navigateIntoZipDir(dirName: String) {+ val current = _zipInternalPath.value+ val newPath = if (current.isEmpty()) dirName else "$current/$dirName"+ _zipInternalPath.value = newPath+ clearSelection()+ loadDirectory()+ }++ fun navigateToZipInternalPath(fullInternalPath: String) {+ // fullInternalPath is the directory path inside zip, e.g. "a/b"+ _zipInternalPath.value = fullInternalPath+ clearSelection()+ loadDirectory()+ }+ fun handleBack(): Boolean { if (_selectedPaths.value.isNotEmpty()) { clearSelection()@@ -191,17 +205,22 @@ class FilesViewModel(application: Application) : AndroidViewModel(application) { val z = _zipPath.value when { z != null -> {- val cur = _currentDirectory.value- if (cur.toString() == "/" || cur.name.isEmpty()) {- navigateTo(z.parent ?: rootDirectory, fs)+ val internal = _zipInternalPath.value+ if (internal.isEmpty()) {+ // Exit zip mode to parent of zip file+ val parent = z.parentFile ?: rootDirectory+ _zipPath.value = null+ _currentDirectory.value = parent } else {- _currentDirectory.value = cur.parent ?: "/".toPath()- loadDirectory()- restartObserver()+ // Go up one level inside zip+ val parentInternal = if (internal.contains("/")) internal.substringBeforeLast("/") else ""+ _zipInternalPath.value = parentInternal }+ loadDirectory()+ restartObserver() } _currentDirectory.value != rootDirectory -> {- _currentDirectory.value = _currentDirectory.value.parent ?: _currentDirectory.value+ _currentDirectory.value = _currentDirectory.value.parentFile ?: _currentDirectory.value loadDirectory() restartObserver() }@@ -212,11 +231,12 @@ class FilesViewModel(application: Application) : AndroidViewModel(application) { // ---- File ops ---- - fun rename(path: Path, newName: String) {- val fileSystem = _currentFileSystem.value+ fun rename(path: File, newName: String) {+ if (isZipMode()) return viewModelScope.launch(Dispatchers.IO) { try {- fileSystem.atomicMove(path, path.parent!!.resolve(newName))+ val target = File(path.parentFile, newName)+ path.atomicMoveTo(target) clearSelection() loadDirectory() } catch (e: Exception) {@@ -226,36 +246,39 @@ class FilesViewModel(application: Application) : AndroidViewModel(application) { } fun deleteSelection() {- val fileSystem = _currentFileSystem.value+ if (isZipMode()) return val selection = _selectedPaths.value viewModelScope.launch(Dispatchers.IO) {- selection.forEach { it.deleteRecursively(fileSystem) }+ selection.forEach { it.deleteRecursively() } clearSelection() loadDirectory() } } - fun moveInto(sources: List<Path>, target: Path) {- if (!target.isDirectory(_currentFileSystem.value)) return- moveFiles(sources, target, _currentFileSystem.value) { source ->- source != target && !target.toString().startsWith(source.toString())+ fun moveInto(sources: List<File>, target: File) {+ if (isZipMode()) return+ if (!target.isDirectory) return+ moveFiles(sources, target) { source ->+ source != target && !target.absolutePath.startsWith(source.absolutePath) } } - fun moveToBreadcrumb(sources: List<Path>, target: Path) {- moveFiles(sources, target, fs) { source ->- source.parent != target && source != target+ fun moveToBreadcrumb(sources: List<File>, target: File) {+ if (isZipMode()) return+ moveFiles(sources, target) { source ->+ source.parentFile != target && source != target } } - private fun moveFiles(sources: List<Path>, target: Path, fileSystem: FileSystem, canMove: (Path) -> Boolean) {+ private fun moveFiles(sources: List<File>, target: File, canMove: (File) -> Boolean) { viewModelScope.launch(Dispatchers.IO) { var movedAny = false var lastError: Exception? = null sources.forEach { source -> if (canMove(source)) { try {- fileSystem.atomicMove(source, target.resolve(source.name))+ val dest = File(target, source.name)+ source.atomicMoveTo(dest) movedAny = true } catch (e: Exception) { lastError = e@@ -270,15 +293,14 @@ class FilesViewModel(application: Application) : AndroidViewModel(application) { } } - /** Try to open [path] as a zip and descend into it. */- fun openZipFile(path: Path) {- val fileSystem = _currentFileSystem.value+ fun openZipFile(path: File) { viewModelScope.launch(Dispatchers.IO) { try {- val zipFs = fileSystem.openZip(path)- if (_zipPath.value == null) _zipPath.value = path- _currentFileSystem.value = zipFs- _currentDirectory.value = "/".toPath()+ // Validate it can be opened+ ZipFile(path).use { _ -> }+ _zipPath.value = path+ _zipInternalPath.value = ""+ _currentDirectory.value = File("/") // fake placeholder for zip root display clearSelection() loadDirectory() restartObserver()@@ -291,17 +313,16 @@ class FilesViewModel(application: Application) : AndroidViewModel(application) { } } - /** Enqueue a [ZipWorker] archiving the current selection into [archiveName] in the current dir. */ fun archive(archiveName: String) {+ if (isZipMode()) return val ctx = getApplication<Application>() val sources = _selectedPaths.value- val destPath = _currentDirectory.value.resolve(- if (archiveName.endsWith(".zip")) archiveName else "$archiveName.zip",- )+ val destFileName = if (archiveName.endsWith(".zip")) archiveName else "$archiveName.zip"+ val destFile = File(_currentDirectory.value, destFileName) val zipWork = OneTimeWorkRequestBuilder<ZipWorker>().setInputData( workDataOf(- "source_paths" to sources.map { it.toString() }.toTypedArray(),- "dest_path" to destPath.toString(),+ "source_paths" to sources.map { it.absolutePath }.toTypedArray(),+ "dest_path" to destFile.absolutePath, ), ).build() WorkManager.getInstance(ctx).enqueue(zipWork)@@ -309,13 +330,12 @@ class FilesViewModel(application: Application) : AndroidViewModel(application) { emit(ctx.getString(R.string.archiving_started)) } - /** Enqueue an [UnzipWorker] for the single selected zip extracting into [destPath]. */- fun unzip(zipPath: Path, destPath: Path) {+ fun unzip(zipPath: File, destPath: File) { val ctx = getApplication<Application>() val unzipWork = OneTimeWorkRequestBuilder<UnzipWorker>().setInputData( workDataOf(- "zip_path" to zipPath.toString(),- "dest_path" to destPath.toString(),+ "zip_path" to zipPath.absolutePath,+ "dest_path" to destPath.absolutePath, ), ).build() WorkManager.getInstance(ctx).enqueue(unzipWork)@@ -323,11 +343,11 @@ class FilesViewModel(application: Application) : AndroidViewModel(application) { emit(ctx.getString(R.string.unzipping_started_to, destPath.name)) } - /** Save any URIs queued in [incomingUris] into [currentDirectory], then clear them. */ fun saveIncomingUris() { val ctx = getApplication<Application>() val uris = _incomingUris.value ?: return val target = _currentDirectory.value+ if (isZipMode()) return viewModelScope.launch(Dispatchers.IO) { uris.forEach { uri -> saveUriToPath(ctx, uri, target) } clearIncomingUris()@@ -336,23 +356,18 @@ class FilesViewModel(application: Application) : AndroidViewModel(application) { } } - /**- * Open [path] with an external app via ACTION_VIEW. The intent is emitted on [intents]- * and launched by MainActivity; in zip-browse mode emits a snackbar instead.- */- fun openFile(path: Path) {+ fun openFile(path: File) { val ctx = getApplication<Application>()- if (_currentFileSystem.value != fs) {+ if (isZipMode()) { emit(ctx.getString(R.string.zip_browse_only)) return }- val file = path.toFile()- val extension = file.extension+ val extension = path.extension val mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension) ?: "*/*" val intent = Intent(Intent.ACTION_VIEW).apply { val uri = FileProvider.getUriForFile(- ctx, "${ctx.packageName}.fileprovider", file,+ ctx, "${ctx.packageName}.fileprovider", path, ) setDataAndType(uri, mimeType) flags = Intent.FLAG_ACTIVITY_NEW_TASK or@@ -377,11 +392,11 @@ class FilesViewModel(application: Application) : AndroidViewModel(application) { ) } - private fun saveUriToPath(context: Context, uri: Uri, targetDir: Path) {+ private fun saveUriToPath(context: Context, uri: Uri, targetDir: File) { val name = getFileName(context, uri) ?: "shared_file_${System.currentTimeMillis()}"- val targetPath = targetDir.resolve(name)+ val targetFile = File(targetDir, name) context.contentResolver.openInputStream(uri)?.use { input ->- fs.write(targetPath) { writeAll(input.source()) }+ targetFile.outputStream().use { out -> input.copyTo(out) } } } @@ -396,4 +411,80 @@ class FilesViewModel(application: Application) : AndroidViewModel(application) { } return uri.path?.substringAfterLast('/') }++ private fun listZipEntries(zipFile: File, internalDir: String): Pair<List<File>, List<File>> {+ return try {+ ZipFile(zipFile).use { zf ->+ val prefix = if (internalDir.isEmpty()) "" else "$internalDir/"+ val childDirNames = mutableSetOf<String>()+ val childFiles = mutableListOf<File>()++ // Collect entries+ val entries = zf.entries().toList()+ for (entry in entries) {+ val name = entry.name+ if (name == internalDir || name == prefix) continue+ if (!name.startsWith(prefix)) continue+ var remainder = name.removePrefix(prefix)+ if (remainder.isEmpty()) continue+ // Skip leading slash if any+ remainder = remainder.trimStart('/')+ if (remainder.isEmpty()) continue+ if (remainder.contains("/")) {+ val first = remainder.substringBefore("/")+ if (first.isNotEmpty()) childDirNames.add(first)+ } else {+ // direct child+ if (entry.isDirectory) {+ childDirNames.add(remainder.trimEnd('/'))+ } else {+ // fake file with name = remainder, path inside zip = prefix+remainder+ // Use a File whose name is remainder and absolutePath encodes internal path for navigation+ val fake = object : File("/zip/$prefix$remainder") {+ override fun getName(): String = remainder+ override fun isDirectory(): Boolean = false+ override fun length(): Long = entry.size.takeIf { it >= 0 } ?: 0L+ }+ childFiles.add(fake)+ }+ }+ }++ // For directories that are implicit (no explicit dir entry), we still have names+ val dirFiles = childDirNames.map { dirName ->+ object : File("/zip/$prefix$dirName") {+ override fun getName(): String = dirName+ override fun isDirectory(): Boolean = true+ override fun length(): Long = 0L+ }+ }++ // For entries list we need real File objects for directories that may have size? we already+ dirFiles.toList() to childFiles.toList()+ }+ } catch (e: Exception) {+ emptyList<File>() to emptyList()+ }+ }++ private fun File.atomicMoveTo(target: File) {+ try {+ java.nio.file.Files.move(+ this.toPath(),+ target.toPath(),+ java.nio.file.StandardCopyOption.ATOMIC_MOVE+ )+ } catch (_: Exception) {+ if (!this.renameTo(target)) {+ // fallback copy+delete+ if (this.isDirectory) {+ this.copyRecursively(target, overwrite = true)+ this.deleteRecursively()+ } else {+ this.copyTo(target, overwrite = true)+ this.delete()+ }+ }+ }+ } }
files/src/main/java/com/vayunmathur/files/util/UnzipWorker.kt
diff --git a/files/src/main/java/com/vayunmathur/files/util/UnzipWorker.kt b/files/src/main/java/com/vayunmathur/files/util/UnzipWorker.ktindex 5d064dab16..32da3d86cc 100644--- a/files/src/main/java/com/vayunmathur/files/util/UnzipWorker.kt+++ b/files/src/main/java/com/vayunmathur/files/util/UnzipWorker.kt@@ -1,11 +1,12 @@ package com.vayunmathur.files.util import android.content.Context import androidx.work.WorkerParameters-import okio.FileSystem-import okio.Path.Companion.toPath-import okio.source-import java.util.zip.ZipInputStream import com.vayunmathur.files.R+import java.io.File+import java.io.FileInputStream+import java.io.FileOutputStream+import java.io.FilterInputStream+import java.util.zip.ZipInputStream class UnzipWorker(context: Context, params: WorkerParameters) : ProgressNotificationWorker( context,@@ -20,19 +21,19 @@ class UnzipWorker(context: Context, params: WorkerParameters) : ProgressNotifica val zipPathString = inputData.getString("zip_path") ?: return Result.failure() val destPathString = inputData.getString("dest_path") ?: return Result.failure() - val zipPath = zipPathString.toPath()- val destPath = destPathString.toPath()+ val zipFile = File(zipPathString)+ val destDir = File(destPathString)+ val destDirCanonical = destDir.canonicalFile createNotificationChannel() setForeground(createForegroundInfo(0)) return try {- val fileSystem = FileSystem.SYSTEM- val zipFileSize = fileSystem.metadataOrNull(zipPath)?.size ?: 0L+ val zipFileSize = zipFile.length() var totalBytesRead = 0L - fileSystem.read(zipPath) {- val countingInputStream = object : java.io.FilterInputStream(inputStream()) {+ FileInputStream(zipFile).use { fis ->+ val countingInputStream = object : FilterInputStream(fis) { override fun read(): Int { val b = super.read() if (b != -1) {@@ -55,19 +56,17 @@ class UnzipWorker(context: Context, params: WorkerParameters) : ProgressNotifica ZipInputStream(countingInputStream).use { zipInputStream -> var entry = zipInputStream.nextEntry while (entry != null) {- val entryFile = java.io.File(destPath.toString(), entry.name).canonicalFile- val destFile = java.io.File(destPath.toString()).canonicalFile- if (!entryFile.path.startsWith(destFile.path)) {+ val entryFile = File(destDir, entry.name).canonicalFile+ if (!entryFile.path.startsWith(destDirCanonical.path)) { entry = zipInputStream.nextEntry continue }- val entryPath = entryFile.path.toPath() if (entry.isDirectory) {- fileSystem.createDirectories(entryPath)+ entryFile.mkdirs() } else {- fileSystem.createDirectories(entryPath.parent!!)- fileSystem.write(entryPath) {- writeAll(zipInputStream.source())+ entryFile.parentFile?.mkdirs()+ FileOutputStream(entryFile).use { out ->+ zipInputStream.copyTo(out) } } zipInputStream.closeEntry()
files/src/main/java/com/vayunmathur/files/util/ZipWorker.kt
diff --git a/files/src/main/java/com/vayunmathur/files/util/ZipWorker.kt b/files/src/main/java/com/vayunmathur/files/util/ZipWorker.ktindex 6272efad21..64b39b951e 100644--- a/files/src/main/java/com/vayunmathur/files/util/ZipWorker.kt+++ b/files/src/main/java/com/vayunmathur/files/util/ZipWorker.kt@@ -1,16 +1,14 @@ package com.vayunmathur.files.util import android.content.Context import androidx.work.WorkerParameters-import okio.Buffer-import okio.FileSystem-import okio.ForwardingSink-import okio.Path-import okio.Path.Companion.toPath-import okio.buffer-import okio.sink+import com.vayunmathur.files.R+import java.io.File+import java.io.FileInputStream+import java.io.FileOutputStream+import java.io.FilterOutputStream+import java.io.OutputStream import java.util.zip.ZipEntry import java.util.zip.ZipOutputStream-import com.vayunmathur.files.R class ZipWorker(context: Context, params: WorkerParameters) : ProgressNotificationWorker( context,@@ -24,23 +22,21 @@ class ZipWorker(context: Context, params: WorkerParameters) : ProgressNotificati override suspend fun doWork(): Result { val sourcePaths = inputData.getStringArray("source_paths") ?: return Result.failure() val destPathString = inputData.getString("dest_path") ?: return Result.failure()- val destPath = destPathString.toPath()+ val destFile = File(destPathString) createNotificationChannel() setForeground(createForegroundInfo(0)) return try {- val fileSystem = FileSystem.SYSTEM- var totalSize = 0L- sourcePaths.forEach { totalSize += calculateTotalSize(fileSystem, it.toPath()) }+ sourcePaths.forEach { totalSize += calculateTotalSize(File(it)) } var bytesZipped = 0L - fileSystem.write(destPath) {- ZipOutputStream(outputStream()).use { zipOutputStream ->+ FileOutputStream(destFile).use { fos ->+ ZipOutputStream(fos).use { zipOut -> sourcePaths.forEach { pathString ->- addToZip(fileSystem, pathString.toPath(), "", zipOutputStream) { bytes ->+ addToZip(File(pathString), "", zipOut) { bytes -> bytesZipped += bytes updateProgress(bytesZipped, totalSize) }@@ -56,43 +52,53 @@ class ZipWorker(context: Context, params: WorkerParameters) : ProgressNotificati } } - private fun calculateTotalSize(fileSystem: FileSystem, path: Path): Long {- val metadata = fileSystem.metadataOrNull(path) ?: return 0L- return if (metadata.isDirectory) fileSystem.list(path).sumOf { calculateTotalSize(fileSystem, it) }- else metadata.size ?: 0L+ private fun calculateTotalSize(file: File): Long {+ if (!file.exists()) return 0L+ return if (file.isDirectory) {+ file.listFiles()?.sumOf { calculateTotalSize(it) } ?: 0L+ } else {+ file.length()+ } } private fun addToZip(- fileSystem: FileSystem,- path: Path,+ file: File, base: String, zipOutputStream: ZipOutputStream, onProgress: (Long) -> Unit ) {- val entryName = if (base.isEmpty()) path.name else "$base/${path.name}"- val metadata = fileSystem.metadataOrNull(path) ?: return+ if (!file.exists()) return+ val entryName = if (base.isEmpty()) file.name else "$base/${file.name}" - if (metadata.isDirectory) {- val children = fileSystem.list(path)- if (children.isEmpty()) {+ if (file.isDirectory) {+ val children = file.listFiles()+ if (children == null || children.isEmpty()) { zipOutputStream.putNextEntry(ZipEntry("$entryName/")) zipOutputStream.closeEntry() } else { children.forEach { child ->- addToZip(fileSystem, child, entryName, zipOutputStream, onProgress)+ addToZip(child, entryName, zipOutputStream, onProgress) } } } else { zipOutputStream.putNextEntry(ZipEntry(entryName))- val countingSink = object : ForwardingSink(zipOutputStream.sink()) {- override fun write(source: Buffer, byteCount: Long) {- super.write(source, byteCount)- onProgress(byteCount)- }- }.buffer()- fileSystem.read(path) { readAll(countingSink) }- countingSink.flush()+ val countingOut = CountingOutputStream(zipOutputStream, onProgress)+ FileInputStream(file).use { input ->+ input.copyTo(countingOut)+ }+ countingOut.flush() zipOutputStream.closeEntry() } }++ private class CountingOutputStream(out: OutputStream, private val onProgress: (Long) -> Unit) : FilterOutputStream(out) {+ override fun write(b: ByteArray, off: Int, len: Int) {+ super.write(b, off, len)+ onProgress(len.toLong())+ }+ override fun write(b: Int) {+ super.write(b)+ onProgress(1)+ }+ } }
gradle/libs.versions.toml
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.tomlindex cc13ba003e..f89a987ea5 100644--- a/gradle/libs.versions.toml+++ b/gradle/libs.versions.toml@@ -82,7 +82,6 @@ okio = "3.17.0" # isolated: contacts/files VCF+zip + messages MetaMqtt/Signal/Wh okhttp = "4.12.0" # isolated: media3-datasource-okhttp (youpipe player) + Vonage SDK (dooraccess) # Images-coilCompose = "2.7.0" androidsvg = "1.4" # Maps & geospatial@@ -234,12 +233,7 @@ brotli-dec = { module = "org.brotli:dec", version.ref = "brotli" } okio = { group = "com.squareup.okio", name = "okio", version.ref = "okio" } # isolated: contacts/files + messages ByteString okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" } # isolated: media3-datasource-okhttp + Vonage SDK -# Images-coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coilCompose" }-coil-svg = { module = "io.coil-kt:coil-svg", version.ref = "coilCompose" }-coil-video = { module = "io.coil-kt:coil-video", version.ref = "coilCompose" }--# Replaces coil-svg+# SVG image decoding via library:image (replaces coil-svg) androidsvg = { module = "com.caverock:androidsvg-aar", version.ref = "androidsvg" } # Maps & geospatial
library/image/src/main/java/com/vayunmathur/library/image/compose/AsyncImageState.kt
diff --git a/library/image/src/main/java/com/vayunmathur/library/image/compose/AsyncImageState.kt b/library/image/src/main/java/com/vayunmathur/library/image/compose/AsyncImageState.ktindex 6a74a878ad..bdf3625594 100644--- a/library/image/src/main/java/com/vayunmathur/library/image/compose/AsyncImageState.kt+++ b/library/image/src/main/java/com/vayunmathur/library/image/compose/AsyncImageState.kt@@ -1,8 +1,6 @@ package com.vayunmathur.library.image.compose -import androidx.compose.ui.geometry.Size as ComposeSize import androidx.compose.ui.graphics.painter.BitmapPainter-import androidx.compose.ui.graphics.asImageBitmap /** * Mirrors Coil's AsyncImagePainter.State hierarchy plus SubcroppedImage usage@@ -20,12 +18,19 @@ sealed class AsyncImageState { } /**- * Back-compat alias – some files check `AsyncImagePainter.State.Success`.- * We expose inner State so `coil.compose.AsyncImagePainter` import migration is easy:- * previously `import coil.compose.AsyncImagePainter` + check `is AsyncImagePainter.State.Success`.- * We provide both `com.vayunmathur.library.image.compose.AsyncImagePainter` and- * the nested `State` alias.+ * Compat shims so legacy checks `is AsyncImagePainter.State.Success` still compile.+ * Coil had `class AsyncImagePainter { sealed class State { ... } }`.+ * We expose both `AsyncImagePainter` object with nested typealias and top-level compat.+ * For best compatibility we also provide a real class `State` via typealias chain – but+ * Kotlin disallows `Typealias.State` resolution in some versions, so we also fix call sites+ * to check `is AsyncImageState.Success`.+ *+ * To keep source compat for any remaining call site that still does+ * `AsyncImagePainter.State.Success`, we expose a wrapper object whose `State` contains `Success` ctor. */ object AsyncImagePainter { typealias State = AsyncImageState }++// Top-level alias for convenience if file did `import coil.compose.AsyncImagePainter` and then `State`+typealias AsyncImagePainterState = AsyncImageState
messages/build.gradle.kts
diff --git a/messages/build.gradle.kts b/messages/build.gradle.ktsindex 043d0e52e7..ea9e3ee42c 100644--- a/messages/build.gradle.kts+++ b/messages/build.gradle.kts@@ -168,9 +168,9 @@ dependencies { // HTTP + streaming for the gmessages / gvoice bridges (HttpURLConnection based). implementation(project(":library:network")) implementation(libs.okio) // isolated: MetaMqtt/WhatsApp uses okio.ByteString+ implementation(libs.okhttp) // Meta Instagram/WhatsApp/Messenger clients use OkHttp directly – was previously transitive via Coil - // Coil — loads device-contact photo URIs (content://) into the- // conversation-row avatars in InboxScreen / ConversationScreen.+ // Async avatar loading via library:image (replaces coil). implementation(project(":library:image")) // CameraX — built-in capture fallback when no system camera app
pdf/src/main/java/com/vayunmathur/pdf/ui/components/SubcroppedImage.kt
diff --git a/pdf/src/main/java/com/vayunmathur/pdf/ui/components/SubcroppedImage.kt b/pdf/src/main/java/com/vayunmathur/pdf/ui/components/SubcroppedImage.ktindex 1a5eed1817..525139b808 100644--- a/pdf/src/main/java/com/vayunmathur/pdf/ui/components/SubcroppedImage.kt+++ b/pdf/src/main/java/com/vayunmathur/pdf/ui/components/SubcroppedImage.kt@@ -22,7 +22,7 @@ import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext import com.vayunmathur.library.image.compose.AsyncImage-import com.vayunmathur.library.image.compose.AsyncImagePainter+import com.vayunmathur.library.image.compose.AsyncImageState import com.vayunmathur.pdf.model.CapturedImage import com.vayunmathur.pdf.model.Quadrilateral import com.vayunmathur.pdf.util.warpQuadToBitmap@@ -99,7 +99,7 @@ private fun BoundingBoxCroppedImage( model = image.uri, contentDescription = null, onState = { state ->- if (state is AsyncImagePainter.State.Success) {+ if (state is AsyncImageState.Success) { painterSize = state.painter.intrinsicSize } },
photos/src/main/java/com/vayunmathur/photos/util/ImageLoader.kt
diff --git a/photos/src/main/java/com/vayunmathur/photos/util/ImageLoader.kt b/photos/src/main/java/com/vayunmathur/photos/util/ImageLoader.ktindex fe84cabf11..4a02f2c378 100644--- a/photos/src/main/java/com/vayunmathur/photos/util/ImageLoader.kt+++ b/photos/src/main/java/com/vayunmathur/photos/util/ImageLoader.kt@@ -38,17 +38,12 @@ object ImageLoader { fun init(context: Context) { imageLoader = LibImageLoader.Builder(context) .memoryCache {- MemoryCache.Builder(context)- .maxSizePercent(0.25) // Use 25% of available RAM- .build()+ MemoryCache.Builder(context).maxSizePercent(0.25).build() } .diskCache {- DiskCache.Builder()- .directory(context.cacheDir.resolve("image_cache"))- .maxSizePercent(0.05) // Use 5% of disk space (or a fixed size like 512MB)- .build()+ DiskCache.Builder().directory(context.cacheDir.resolve("image_cache")).maxSizePercent(0.05).build() }- .respectCacheHeaders(false) // Important for local files/mediastore+ .respectCacheHeaders(false) .build() } @@ -68,11 +63,11 @@ object ImageLoader { AsyncImage( model = ImageRequest.Builder(context) .data(photo.uri.toUri())- .videoFrameMillis(1000) // Grabs frame at 1s mark+ .videoFrameMillis(1000) .diskCacheKey("thumb_${photo.id}_${photo.dateModified}") .memoryCacheKey("thumb_${photo.id}_${photo.dateModified}") .crossfade(true)- .size(256) // Increased slightly for better quality on high-DPI screens+ .size(256) .build(), imageLoader = imageLoader, contentDescription = null,@@ -81,7 +76,6 @@ object ImageLoader { ) if (isVideo) {- // Semi-transparent circle background for the icon Box( modifier = Modifier .size(32.dp)@@ -141,7 +135,6 @@ object ImageLoader { color = Color.Black.copy(alpha = 0.3f), modifier = Modifier.size(24.dp) ) {- // Empty circle } } }
youpipe/build.gradle.kts
diff --git a/youpipe/build.gradle.kts b/youpipe/build.gradle.ktsindex 93b1d07194..68a2c19ac8 100644--- a/youpipe/build.gradle.kts+++ b/youpipe/build.gradle.kts@@ -26,7 +26,6 @@ android { dependencies { implementation(project(":library:image")) implementation(project(":youpipe:extractor"))- implementation(project(":third_party:nanojson")) implementation(libs.quickjs.kt) implementation(libs.androidx.webkit)
youpipe/extractor/build.gradle.kts
diff --git a/youpipe/extractor/build.gradle.kts b/youpipe/extractor/build.gradle.ktsindex 6683bbfa78..58a5e92c44 100644--- a/youpipe/extractor/build.gradle.kts+++ b/youpipe/extractor/build.gradle.kts@@ -1,32 +1,10 @@-import org.gradle.api.JavaVersion-import org.gradle.api.tasks.bundling.AbstractArchiveTask- plugins {- `java-library`+ id("common-conventions-jvm") alias(libs.plugins.protobuf) } -java {- sourceCompatibility = JavaVersion.VERSION_17- targetCompatibility = JavaVersion.VERSION_17-}--tasks.withType<AbstractArchiveTask>().configureEach {- isPreserveFileTimestamps = false- isReproducibleFileOrder = true-}--// Protobuf files would uselessly end up in the JAR otherwise, see-// https://github.com/google/protobuf-gradle-plugin/issues/390-tasks.jar {- exclude("**/*.proto")- includeEmptyDirs = false- isPreserveFileTimestamps = false- isReproducibleFileOrder = true-}- dependencies {- implementation(project(":third_party:nanojson"))+ // nanojson removed — replaced by kotlinx.serialization-json via common-conventions-jvm implementation(libs.jsoup) implementation(libs.google.jsr305) implementation(libs.protobuf.javalite)
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.javadeleted file mode 100644index 90fda6ad04..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java+++ /dev/null@@ -1,58 +0,0 @@-/*- * Created by Christian Schabesberger on 25.07.16.- *- * Copyright (C) 2016 Christian Schabesberger <[email protected]>- * ChannelExtractor.java is part of NewPipe Extractor.- *- * NewPipe Extractor is free software: you can redistribute it and/or modify- * it under the terms of the GNU General Public License as published by- * the Free Software Foundation, either version 3 of the License, or- * (at your option) any later version.- *- * NewPipe Extractor is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU General Public License for more details.- *- * You should have received a copy of the GNU General Public License- * along with NewPipe Extractor. If not, see <https://www.gnu.org/licenses/>.- */--package org.schabi.newpipe.extractor.channel;--import org.schabi.newpipe.extractor.Extractor;-import org.schabi.newpipe.extractor.Image;-import org.schabi.newpipe.extractor.StreamingService;-import org.schabi.newpipe.extractor.exceptions.ParsingException;-import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;--import javax.annotation.Nonnull;-import java.util.List;--public abstract class ChannelExtractor extends Extractor {-- public static final long UNKNOWN_SUBSCRIBER_COUNT = -1;-- protected ChannelExtractor(final StreamingService service, final ListLinkHandler linkHandler) {- super(service, linkHandler);- }-- @Nonnull- public abstract List<Image> getAvatars() throws ParsingException;- @Nonnull- public abstract List<Image> getBanners() throws ParsingException;- public abstract String getFeedUrl() throws ParsingException;- public abstract long getSubscriberCount() throws ParsingException;- public abstract String getDescription() throws ParsingException;- public abstract String getParentChannelName() throws ParsingException;- public abstract String getParentChannelUrl() throws ParsingException;- @Nonnull- public abstract List<Image> getParentChannelAvatars() throws ParsingException;- public abstract boolean isVerified() throws ParsingException;- @Nonnull- public abstract List<ListLinkHandler> getTabs() throws ParsingException;- @Nonnull- public List<String> getTags() throws ParsingException {- return List.of();- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.javadeleted file mode 100644index edb4b393ba..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java+++ /dev/null@@ -1,252 +0,0 @@-/*- * Created by Christian Schabesberger on 31.07.16.- *- * Copyright (C) 2016 Christian Schabesberger <[email protected]>- * ChannelInfo.java is part of NewPipe Extractor.- *- * NewPipe Extractor is free software: you can redistribute it and/or modify- * it under the terms of the GNU General Public License as published by- * the Free Software Foundation, either version 3 of the License, or- * (at your option) any later version.- *- * NewPipe Extractor is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU General Public License for more details.- *- * You should have received a copy of the GNU General Public License- * along with NewPipe Extractor. If not, see <https://www.gnu.org/licenses/>.- */--package org.schabi.newpipe.extractor.channel;--import org.schabi.newpipe.extractor.Info;-import org.schabi.newpipe.extractor.Image;-import org.schabi.newpipe.extractor.NewPipe;-import org.schabi.newpipe.extractor.StreamingService;-import org.schabi.newpipe.extractor.exceptions.ExtractionException;-import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;--import java.io.IOException;-import java.util.List;--import javax.annotation.Nonnull;--public class ChannelInfo extends Info {-- public ChannelInfo(final int serviceId,- final String id,- final String url,- final String originalUrl,- final String name) {- super(serviceId, id, url, originalUrl, name);- }-- public static ChannelInfo getInfo(final String url) throws IOException, ExtractionException {- return getInfo(NewPipe.getServiceByUrl(url), url);- }-- public static ChannelInfo getInfo(final StreamingService service, final String url)- throws IOException, ExtractionException {- final ChannelExtractor extractor = service.getChannelExtractor(url);- extractor.fetchPage();- return getInfo(extractor);- }-- public static ChannelInfo getInfo(final ChannelExtractor extractor)- throws IOException, ExtractionException {-- final int serviceId = extractor.getServiceId();- final String id = extractor.getId();- final String url = extractor.getUrl();- final String originalUrl = extractor.getOriginalUrl();- final String name = extractor.getName();-- final ChannelInfo info = new ChannelInfo(serviceId, id, url, originalUrl, name);-- try {- info.setAvatars(extractor.getAvatars());- } catch (final Exception e) {- info.addError(e);- }-- try {- info.setBanners(extractor.getBanners());- } catch (final Exception e) {- info.addError(e);- }-- try {- info.setFeedUrl(extractor.getFeedUrl());- } catch (final Exception e) {- info.addError(e);- }-- try {- info.setSubscriberCount(extractor.getSubscriberCount());- } catch (final Exception e) {- info.addError(e);- }-- try {- info.setDescription(extractor.getDescription());- } catch (final Exception e) {- info.addError(e);- }-- try {- info.setParentChannelName(extractor.getParentChannelName());- } catch (final Exception e) {- info.addError(e);- }-- try {- info.setParentChannelUrl(extractor.getParentChannelUrl());- } catch (final Exception e) {- info.addError(e);- }-- try {- info.setParentChannelAvatars(extractor.getParentChannelAvatars());- } catch (final Exception e) {- info.addError(e);- }-- try {- info.setVerified(extractor.isVerified());- } catch (final Exception e) {- info.addError(e);- }-- try {- info.setTabs(extractor.getTabs());- } catch (final Exception e) {- info.addError(e);- }-- try {- info.setTags(extractor.getTags());- } catch (final Exception e) {- info.addError(e);- }-- return info;- }-- private String parentChannelName;- private String parentChannelUrl;- private String feedUrl;- private long subscriberCount = -1;- private String description;- private String[] donationLinks;- @Nonnull- private List<Image> avatars = List.of();- @Nonnull- private List<Image> banners = List.of();- @Nonnull- private List<Image> parentChannelAvatars = List.of();- private boolean verified;- private List<ListLinkHandler> tabs = List.of();- private List<String> tags = List.of();-- public String getParentChannelName() {- return parentChannelName;- }-- public void setParentChannelName(final String parentChannelName) {- this.parentChannelName = parentChannelName;- }-- public String getParentChannelUrl() {- return parentChannelUrl;- }-- public void setParentChannelUrl(final String parentChannelUrl) {- this.parentChannelUrl = parentChannelUrl;- }-- @Nonnull- public List<Image> getParentChannelAvatars() {- return parentChannelAvatars;- }-- public void setParentChannelAvatars(@Nonnull final List<Image> parentChannelAvatars) {- this.parentChannelAvatars = parentChannelAvatars;- }-- @Nonnull- public List<Image> getAvatars() {- return avatars;- }-- public void setAvatars(@Nonnull final List<Image> avatars) {- this.avatars = avatars;- }-- @Nonnull- public List<Image> getBanners() {- return banners;- }-- public void setBanners(@Nonnull final List<Image> banners) {- this.banners = banners;- }-- public String getFeedUrl() {- return feedUrl;- }-- public void setFeedUrl(final String feedUrl) {- this.feedUrl = feedUrl;- }-- public long getSubscriberCount() {- return subscriberCount;- }-- public void setSubscriberCount(final long subscriberCount) {- this.subscriberCount = subscriberCount;- }-- public String getDescription() {- return description;- }-- public void setDescription(final String description) {- this.description = description;- }-- public String[] getDonationLinks() {- return donationLinks;- }-- public void setDonationLinks(final String[] donationLinks) {- this.donationLinks = donationLinks;- }-- public boolean isVerified() {- return verified;- }-- public void setVerified(final boolean verified) {- this.verified = verified;- }-- @Nonnull- public List<ListLinkHandler> getTabs() {- return tabs;- }-- public void setTabs(@Nonnull final List<ListLinkHandler> tabs) {- this.tabs = tabs;- }-- @Nonnull- public List<String> getTags() {- return tags;- }-- public void setTags(@Nonnull final List<String> tags) {- this.tags = tags;- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItem.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItem.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItem.javadeleted file mode 100644index e12801886c..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItem.java+++ /dev/null@@ -1,67 +0,0 @@-package org.schabi.newpipe.extractor.channel;--import org.schabi.newpipe.extractor.InfoItem;--/*- * Created by Christian Schabesberger on 11.02.17.- *- * Copyright (C) 2017 Christian Schabesberger <[email protected]>- * ChannelInfoItem.java is part of NewPipe Extractor.- *- * NewPipe Extractor is free software: you can redistribute it and/or modify- * it under the terms of the GNU General Public License as published by- * the Free Software Foundation, either version 3 of the License, or- * (at your option) any later version.- *- * NewPipe Extractor is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU General Public License for more details.- *- * You should have received a copy of the GNU General Public License- * along with NewPipe Extractor. If not, see <http://www.gnu.org/licenses/>.- */--public class ChannelInfoItem extends InfoItem {-- private String description;- private long subscriberCount = -1;- private long streamCount = -1;- private boolean verified = false;-- public ChannelInfoItem(final int serviceId, final String url, final String name) {- super(InfoType.CHANNEL, serviceId, url, name);- }-- public String getDescription() {- return description;- }-- public void setDescription(final String description) {- this.description = description;- }-- public long getSubscriberCount() {- return subscriberCount;- }-- public void setSubscriberCount(final long subscriberCount) {- this.subscriberCount = subscriberCount;- }-- public long getStreamCount() {- return streamCount;- }-- public void setStreamCount(final long streamCount) {- this.streamCount = streamCount;- }-- public boolean isVerified() {- return verified;- }-- public void setVerified(final boolean verified) {- this.verified = verified;- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemExtractor.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemExtractor.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemExtractor.javadeleted file mode 100644index 6f1b01c913..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemExtractor.java+++ /dev/null@@ -1,34 +0,0 @@-package org.schabi.newpipe.extractor.channel;--import org.schabi.newpipe.extractor.InfoItemExtractor;-import org.schabi.newpipe.extractor.exceptions.ParsingException;--/*- * Created by Christian Schabesberger on 12.02.17.- *- * Copyright (C) 2017 Christian Schabesberger <[email protected]>- * ChannelInfoItemExtractor.java is part of NewPipe Extractor.- *- * NewPipe Extractor is free software: you can redistribute it and/or modify- * it under the terms of the GNU General Public License as published by- * the Free Software Foundation, either version 3 of the License, or- * (at your option) any later version.- *- * NewPipe Extractor is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU General Public License for more details.- *- * You should have received a copy of the GNU General Public License- * along with NewPipe Extractor. If not, see <http://www.gnu.org/licenses/>.- */--public interface ChannelInfoItemExtractor extends InfoItemExtractor {- String getDescription() throws ParsingException;-- long getSubscriberCount() throws ParsingException;-- long getStreamCount() throws ParsingException;-- boolean isVerified() throws ParsingException;-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.javadeleted file mode 100644index 5e4f383cbb..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.java+++ /dev/null@@ -1,67 +0,0 @@-/*- * Created by Christian Schabesberger on 12.02.17.- *- * Copyright (C) 2017 Christian Schabesberger <[email protected]>- * ChannelInfoItemsCollector.java is part of NewPipe Extractor.- *- * NewPipe Extractor is free software: you can redistribute it and/or modify- * it under the terms of the GNU General Public License as published by- * the Free Software Foundation, either version 3 of the License, or- * (at your option) any later version.- *- * NewPipe Extractor is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU General Public License for more details.- *- * You should have received a copy of the GNU General Public License- * along with NewPipe Extractor. If not, see <https://www.gnu.org/licenses/>.- */--package org.schabi.newpipe.extractor.channel;--import org.schabi.newpipe.extractor.InfoItemsCollector;-import org.schabi.newpipe.extractor.exceptions.ParsingException;--public final class ChannelInfoItemsCollector- extends InfoItemsCollector<ChannelInfoItem, ChannelInfoItemExtractor> {- public ChannelInfoItemsCollector(final int serviceId) {- super(serviceId);- }-- @Override- public ChannelInfoItem extract(final ChannelInfoItemExtractor extractor)- throws ParsingException {- final ChannelInfoItem resultItem = new ChannelInfoItem(- getServiceId(), extractor.getUrl(), extractor.getName());-- // optional information- try {- resultItem.setSubscriberCount(extractor.getSubscriberCount());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setStreamCount(extractor.getStreamCount());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setThumbnails(extractor.getThumbnails());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setDescription(extractor.getDescription());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setVerified(extractor.isVerified());- } catch (final Exception e) {- addError(e);- }-- return resultItem;- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabExtractor.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabExtractor.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabExtractor.javadeleted file mode 100644index 79b6d26308..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabExtractor.java+++ /dev/null@@ -1,25 +0,0 @@-package org.schabi.newpipe.extractor.channel.tabs;--import org.schabi.newpipe.extractor.InfoItem;-import org.schabi.newpipe.extractor.ListExtractor;-import org.schabi.newpipe.extractor.StreamingService;-import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;--import javax.annotation.Nonnull;--/**- * A {@link ListExtractor} of {@link InfoItem}s for tabs of channels.- */-public abstract class ChannelTabExtractor extends ListExtractor<InfoItem> {-- protected ChannelTabExtractor(@Nonnull final StreamingService service,- @Nonnull final ListLinkHandler linkHandler) {- super(service, linkHandler);- }-- @Nonnull- @Override- public String getName() {- return getLinkHandler().getContentFilters().get(0);- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabInfo.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabInfo.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabInfo.javadeleted file mode 100644index 8bc9fbfa78..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabInfo.java+++ /dev/null@@ -1,70 +0,0 @@-package org.schabi.newpipe.extractor.channel.tabs;--import org.schabi.newpipe.extractor.InfoItem;-import org.schabi.newpipe.extractor.ListExtractor;-import org.schabi.newpipe.extractor.ListInfo;-import org.schabi.newpipe.extractor.Page;-import org.schabi.newpipe.extractor.StreamingService;-import org.schabi.newpipe.extractor.channel.ChannelInfo;-import org.schabi.newpipe.extractor.exceptions.ExtractionException;-import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;-import org.schabi.newpipe.extractor.utils.ExtractorHelper;--import javax.annotation.Nonnull;-import java.io.IOException;--public class ChannelTabInfo extends ListInfo<InfoItem> {-- public ChannelTabInfo(final int serviceId,- @Nonnull final ListLinkHandler linkHandler) {- super(serviceId, linkHandler, linkHandler.getContentFilters().get(0));- }-- /**- * Get a {@link ChannelTabInfo} instance from the given service and tab handler.- *- * @param service streaming service- * @param linkHandler Channel tab handler (from {@link ChannelInfo})- * @return the extracted {@link ChannelTabInfo}- */- @Nonnull- public static ChannelTabInfo getInfo(@Nonnull final StreamingService service,- @Nonnull final ListLinkHandler linkHandler)- throws ExtractionException, IOException {- final ChannelTabExtractor extractor = service.getChannelTabExtractor(linkHandler);- extractor.fetchPage();- return getInfo(extractor);- }-- /**- * Get a {@link ChannelTabInfo} instance from a {@link ChannelTabExtractor}.- *- * @param extractor an extractor where {@code fetchPage()} was already got called on- * @return the extracted {@link ChannelTabInfo}- */- @Nonnull- public static ChannelTabInfo getInfo(@Nonnull final ChannelTabExtractor extractor) {- final ChannelTabInfo info =- new ChannelTabInfo(extractor.getServiceId(), extractor.getLinkHandler());-- try {- info.setOriginalUrl(extractor.getOriginalUrl());- } catch (final Exception e) {- info.addError(e);- }-- final ListExtractor.InfoItemsPage<InfoItem> page- = ExtractorHelper.getItemsPageOrLogError(info, extractor);- info.setRelatedItems(page.getItems());- info.setNextPage(page.getNextPage());-- return info;- }-- public static ListExtractor.InfoItemsPage<InfoItem> getMoreItems(- @Nonnull final StreamingService service,- @Nonnull final ListLinkHandler linkHandler,- @Nonnull final Page page) throws ExtractionException, IOException {- return service.getChannelTabExtractor(linkHandler).getPage(page);- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabs.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabs.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabs.javadeleted file mode 100644index 68b0ca4304..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/channel/tabs/ChannelTabs.java+++ /dev/null@@ -1,18 +0,0 @@-package org.schabi.newpipe.extractor.channel.tabs;--/**- * Constants of channel tabs supported by the extractor.- */-public final class ChannelTabs {- public static final String VIDEOS = "videos";- public static final String TRACKS = "tracks";- public static final String SHORTS = "shorts";- public static final String LIVESTREAMS = "livestreams";- public static final String CHANNELS = "channels";- public static final String PLAYLISTS = "playlists";- public static final String ALBUMS = "albums";- public static final String LIKES = "likes";-- private ChannelTabs() {- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsExtractor.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsExtractor.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsExtractor.javadeleted file mode 100644index 1402b1d234..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsExtractor.java+++ /dev/null@@ -1,37 +0,0 @@-package org.schabi.newpipe.extractor.comments;--import org.schabi.newpipe.extractor.ListExtractor;-import org.schabi.newpipe.extractor.StreamingService;-import org.schabi.newpipe.extractor.exceptions.ExtractionException;-import org.schabi.newpipe.extractor.exceptions.ParsingException;-import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;--import javax.annotation.Nonnull;--public abstract class CommentsExtractor extends ListExtractor<CommentsInfoItem> {-- public CommentsExtractor(final StreamingService service, final ListLinkHandler uiHandler) {- super(service, uiHandler);- }-- /**- * @apiNote Warning: This method is experimental and may get removed in a future release.- * @return <code>true</code> if the comments are disabled otherwise <code>false</code> (default)- */- public boolean isCommentsDisabled() throws ExtractionException {- return false;- }-- /**- * @return the total number of comments- */- public int getCommentsCount() throws ExtractionException {- return -1;- }-- @Nonnull- @Override- public String getName() throws ParsingException {- return "Comments";- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfo.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfo.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfo.javadeleted file mode 100644index f50d6bd998..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfo.java+++ /dev/null@@ -1,126 +0,0 @@-package org.schabi.newpipe.extractor.comments;--import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;-import org.schabi.newpipe.extractor.ListInfo;-import org.schabi.newpipe.extractor.NewPipe;-import org.schabi.newpipe.extractor.Page;-import org.schabi.newpipe.extractor.StreamingService;-import org.schabi.newpipe.extractor.exceptions.ExtractionException;-import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;-import org.schabi.newpipe.extractor.utils.ExtractorHelper;--import java.io.IOException;--public final class CommentsInfo extends ListInfo<CommentsInfoItem> {-- private CommentsInfo(- final int serviceId,- final ListLinkHandler listUrlIdHandler,- final String name) {- super(serviceId, listUrlIdHandler, name);- }-- public static CommentsInfo getInfo(final String url) throws IOException, ExtractionException {- return getInfo(NewPipe.getServiceByUrl(url), url);- }-- public static CommentsInfo getInfo(final StreamingService service, final String url)- throws ExtractionException, IOException {- return getInfo(service.getCommentsExtractor(url));- }-- public static CommentsInfo getInfo(final CommentsExtractor commentsExtractor)- throws IOException, ExtractionException {- // for services which do not have a comments extractor- if (commentsExtractor == null) {- return null;- }-- commentsExtractor.fetchPage();-- final String name = commentsExtractor.getName();- final int serviceId = commentsExtractor.getServiceId();- final ListLinkHandler listUrlIdHandler = commentsExtractor.getLinkHandler();-- final CommentsInfo commentsInfo = new CommentsInfo(serviceId, listUrlIdHandler, name);- commentsInfo.setCommentsExtractor(commentsExtractor);- final InfoItemsPage<CommentsInfoItem> initialCommentsPage =- ExtractorHelper.getItemsPageOrLogError(commentsInfo, commentsExtractor);- commentsInfo.setCommentsDisabled(commentsExtractor.isCommentsDisabled());- commentsInfo.setRelatedItems(initialCommentsPage.getItems());- try {- commentsInfo.setCommentsCount(commentsExtractor.getCommentsCount());- } catch (final Exception e) {- commentsInfo.addError(e);- }- commentsInfo.setNextPage(initialCommentsPage.getNextPage());-- return commentsInfo;- }-- public static InfoItemsPage<CommentsInfoItem> getMoreItems(- final CommentsInfo commentsInfo,- final Page page) throws ExtractionException, IOException {- return getMoreItems(NewPipe.getService(commentsInfo.getServiceId()), commentsInfo.getUrl(),- page);- }-- public static InfoItemsPage<CommentsInfoItem> getMoreItems(- final StreamingService service,- final CommentsInfo commentsInfo,- final Page page) throws IOException, ExtractionException {- return getMoreItems(service, commentsInfo.getUrl(), page);- }-- public static InfoItemsPage<CommentsInfoItem> getMoreItems(- final StreamingService service,- final String url,- final Page page) throws IOException, ExtractionException {- return service.getCommentsExtractor(url).getPage(page);- }-- private transient CommentsExtractor commentsExtractor;- private boolean commentsDisabled = false;- private int commentsCount;-- public CommentsExtractor getCommentsExtractor() {- return commentsExtractor;- }-- public void setCommentsExtractor(final CommentsExtractor commentsExtractor) {- this.commentsExtractor = commentsExtractor;- }-- /**- * @return {@code true} if the comments are disabled otherwise {@code false} (default)- * @see CommentsExtractor#isCommentsDisabled()- */- public boolean isCommentsDisabled() {- return commentsDisabled;- }-- /**- * @param commentsDisabled {@code true} if the comments are disabled otherwise {@code false}- */- public void setCommentsDisabled(final boolean commentsDisabled) {- this.commentsDisabled = commentsDisabled;- }-- /**- * Returns the total number of comments.- *- * @return the total number of comments- */- public int getCommentsCount() {- return commentsCount;- }-- /**- * Sets the total number of comments.- *- * @param commentsCount the commentsCount to set.- */- public void setCommentsCount(final int commentsCount) {- this.commentsCount = commentsCount;- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItem.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItem.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItem.javadeleted file mode 100644index 1b4379f807..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItem.java+++ /dev/null@@ -1,197 +0,0 @@-package org.schabi.newpipe.extractor.comments;--import org.schabi.newpipe.extractor.Image;-import org.schabi.newpipe.extractor.InfoItem;-import org.schabi.newpipe.extractor.Page;-import org.schabi.newpipe.extractor.localization.DateWrapper;-import org.schabi.newpipe.extractor.stream.Description;--import javax.annotation.Nonnull;-import javax.annotation.Nullable;-import java.util.List;--public class CommentsInfoItem extends InfoItem {-- private String commentId;- @Nonnull- private Description commentText = Description.EMPTY_DESCRIPTION;- private String uploaderName;- @Nonnull- private List<Image> uploaderAvatars = List.of();- private String uploaderUrl;- private boolean uploaderVerified;- private String textualUploadDate;- @Nullable- private DateWrapper uploadDate;- private int likeCount;- private String textualLikeCount;- private boolean heartedByUploader;- private boolean pinned;- private int streamPosition;- private int replyCount;- @Nullable- private Page replies;- private boolean isChannelOwner;- private boolean creatorReply;-- public static final int NO_LIKE_COUNT = -1;- public static final int NO_STREAM_POSITION = -1;-- public static final int UNKNOWN_REPLY_COUNT = -1;-- public CommentsInfoItem(final int serviceId, final String url, final String name) {- super(InfoType.COMMENT, serviceId, url, name);- }-- public String getCommentId() {- return commentId;- }-- public void setCommentId(final String commentId) {- this.commentId = commentId;- }-- @Nonnull- public Description getCommentText() {- return commentText;- }-- public void setCommentText(@Nonnull final Description commentText) {- this.commentText = commentText;- }-- public String getUploaderName() {- return uploaderName;- }-- public void setUploaderName(final String uploaderName) {- this.uploaderName = uploaderName;- }-- @Nonnull- public List<Image> getUploaderAvatars() {- return uploaderAvatars;- }-- public void setUploaderAvatars(@Nonnull final List<Image> uploaderAvatars) {- this.uploaderAvatars = uploaderAvatars;- }-- public String getUploaderUrl() {- return uploaderUrl;- }-- public void setUploaderUrl(final String uploaderUrl) {- this.uploaderUrl = uploaderUrl;- }-- public String getTextualUploadDate() {- return textualUploadDate;- }-- public void setTextualUploadDate(final String textualUploadDate) {- this.textualUploadDate = textualUploadDate;- }-- @Nullable- public DateWrapper getUploadDate() {- return uploadDate;- }-- public void setUploadDate(@Nullable final DateWrapper uploadDate) {- this.uploadDate = uploadDate;- }-- /**- * @return the comment's like count or {@link CommentsInfoItem#NO_LIKE_COUNT} if it is- * unavailable- */- public int getLikeCount() {- return likeCount;- }-- public void setLikeCount(final int likeCount) {- this.likeCount = likeCount;- }-- public String getTextualLikeCount() {- return textualLikeCount;- }-- public void setTextualLikeCount(final String textualLikeCount) {- this.textualLikeCount = textualLikeCount;- }-- public void setHeartedByUploader(final boolean isHeartedByUploader) {- this.heartedByUploader = isHeartedByUploader;- }-- public boolean isHeartedByUploader() {- return this.heartedByUploader;- }-- public boolean isPinned() {- return pinned;- }-- public void setPinned(final boolean pinned) {- this.pinned = pinned;- }-- public void setUploaderVerified(final boolean uploaderVerified) {- this.uploaderVerified = uploaderVerified;- }-- public boolean isUploaderVerified() {- return uploaderVerified;- }-- public void setStreamPosition(final int streamPosition) {- this.streamPosition = streamPosition;- }-- /**- * Get the playback position of the stream to which this comment belongs.- * This is not supported by all services.- *- * @return the playback position in seconds or {@link #NO_STREAM_POSITION} if not available- */- public int getStreamPosition() {- return streamPosition;- }-- public void setReplyCount(final int replyCount) {- this.replyCount = replyCount;- }-- public int getReplyCount() {- return replyCount;- }-- public void setReplies(@Nullable final Page replies) {- this.replies = replies;- }-- @Nullable- public Page getReplies() {- return this.replies;- }-- public void setChannelOwner(final boolean channelOwner) {- this.isChannelOwner = channelOwner;- }-- public boolean isChannelOwner() {- return isChannelOwner;- }--- public void setCreatorReply(final boolean creatorReply) {- this.creatorReply = creatorReply;- }-- public boolean hasCreatorReply() {- return creatorReply;- }--}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.javadeleted file mode 100644index 7bae95c2c2..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.java+++ /dev/null@@ -1,152 +0,0 @@-package org.schabi.newpipe.extractor.comments;--import org.schabi.newpipe.extractor.Image;-import org.schabi.newpipe.extractor.InfoItemExtractor;-import org.schabi.newpipe.extractor.Page;-import org.schabi.newpipe.extractor.exceptions.ParsingException;-import org.schabi.newpipe.extractor.localization.DateWrapper;-import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeCommentsInfoItemExtractor;-import org.schabi.newpipe.extractor.stream.Description;-import org.schabi.newpipe.extractor.stream.StreamExtractor;--import javax.annotation.Nonnull;-import javax.annotation.Nullable;-import java.util.List;--public interface CommentsInfoItemExtractor extends InfoItemExtractor {-- /**- * Return the like count of the comment,- * or {@link CommentsInfoItem#NO_LIKE_COUNT} if it is unavailable.- *- * <br>- * <p>- * NOTE: Currently only implemented for YT {@link- * YoutubeCommentsInfoItemExtractor#getLikeCount()}- * with limitations (only approximate like count is returned)- *- * @return the comment's like count- * or {@link CommentsInfoItem#NO_LIKE_COUNT} if it is unavailable- * @see StreamExtractor#getLikeCount()- */- default int getLikeCount() throws ParsingException {- return CommentsInfoItem.NO_LIKE_COUNT;- }-- /**- * The unmodified like count given by the service- * <br>- * It may be language dependent- */- default String getTextualLikeCount() throws ParsingException {- return "";- }-- /**- * The text of the comment- */- @Nonnull- default Description getCommentText() throws ParsingException {- return Description.EMPTY_DESCRIPTION;- }-- /**- * The upload date given by the service, unmodified- *- * @see StreamExtractor#getTextualUploadDate()- */- default String getTextualUploadDate() throws ParsingException {- return "";- }-- /**- * The upload date wrapped with DateWrapper class- *- * @see StreamExtractor#getUploadDate()- */- @Nullable- default DateWrapper getUploadDate() throws ParsingException {- return null;- }-- default String getCommentId() throws ParsingException {- return "";- }-- default String getUploaderUrl() throws ParsingException {- return "";- }-- default String getUploaderName() throws ParsingException {- return "";- }-- @Nonnull- default List<Image> getUploaderAvatars() throws ParsingException {- return List.of();- }-- /**- * Whether the comment has been hearted by the uploader- */- default boolean isHeartedByUploader() throws ParsingException {- return false;- }-- /**- * Whether the comment is pinned- */- default boolean isPinned() throws ParsingException {- return false;- }-- /**- * Whether the uploader is verified by the service- */- default boolean isUploaderVerified() throws ParsingException {- return false;- }-- /**- * The playback position of the stream to which this comment belongs.- *- * @see CommentsInfoItem#getStreamPosition()- */- default int getStreamPosition() throws ParsingException {- return CommentsInfoItem.NO_STREAM_POSITION;- }-- /**- * The count of comment replies.- *- * @return the count of the replies- * or {@link CommentsInfoItem#UNKNOWN_REPLY_COUNT} if replies are not supported- */- default int getReplyCount() throws ParsingException {- return CommentsInfoItem.UNKNOWN_REPLY_COUNT;- }-- /**- * The continuation page which is used to get comment replies from.- *- * @return the continuation Page for the replies, or null if replies are not supported- */- @Nullable- default Page getReplies() throws ParsingException {- return null;- }-- /**- * Whether the comment was made by the channel owner.- */- default boolean isChannelOwner() throws ParsingException {- return false;- }-- /**- * Whether the comment was replied to by the creator.- */- default boolean hasCreatorReply() throws ParsingException {- return false;- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemsCollector.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemsCollector.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemsCollector.javadeleted file mode 100644index ff912bb0f9..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemsCollector.java+++ /dev/null@@ -1,133 +0,0 @@-package org.schabi.newpipe.extractor.comments;--import org.schabi.newpipe.extractor.InfoItemsCollector;-import org.schabi.newpipe.extractor.exceptions.ParsingException;--import java.util.ArrayList;-import java.util.List;--public final class CommentsInfoItemsCollector- extends InfoItemsCollector<CommentsInfoItem, CommentsInfoItemExtractor> {-- public CommentsInfoItemsCollector(final int serviceId) {- super(serviceId);- }-- @Override- public CommentsInfoItem extract(final CommentsInfoItemExtractor extractor)- throws ParsingException {- final CommentsInfoItem resultItem = new CommentsInfoItem(- getServiceId(), extractor.getUrl(), extractor.getName());-- // optional information- try {- resultItem.setCommentId(extractor.getCommentId());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setCommentText(extractor.getCommentText());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setUploaderName(extractor.getUploaderName());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setUploaderAvatars(extractor.getUploaderAvatars());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setUploaderUrl(extractor.getUploaderUrl());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setTextualUploadDate(extractor.getTextualUploadDate());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setUploadDate(extractor.getUploadDate());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setLikeCount(extractor.getLikeCount());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setTextualLikeCount(extractor.getTextualLikeCount());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setThumbnails(extractor.getThumbnails());- } catch (final Exception e) {- addError(e);- }-- try {- resultItem.setHeartedByUploader(extractor.isHeartedByUploader());- } catch (final Exception e) {- addError(e);- }-- try {- resultItem.setPinned(extractor.isPinned());- } catch (final Exception e) {- addError(e);- }-- try {- resultItem.setStreamPosition(extractor.getStreamPosition());- } catch (final Exception e) {- addError(e);- }-- try {- resultItem.setReplyCount(extractor.getReplyCount());- } catch (final Exception e) {- addError(e);- }-- try {- resultItem.setReplies(extractor.getReplies());- } catch (final Exception e) {- addError(e);- }-- try {- resultItem.setChannelOwner(extractor.isChannelOwner());- } catch (final Exception e) {- addError(e);- }--- try {- resultItem.setCreatorReply(extractor.hasCreatorReply());- } catch (final Exception e) {- addError(e);- }--- return resultItem;- }-- @Override- public void commit(final CommentsInfoItemExtractor extractor) {- try {- addItem(extract(extractor));- } catch (final Exception e) {- addError(e);- }- }-- public List<CommentsInfoItem> getCommentsInfoItemList() {- return new ArrayList<>(super.getItems());- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/feed/FeedExtractor.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/feed/FeedExtractor.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/feed/FeedExtractor.javadeleted file mode 100644index 42b5a0cbfc..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/feed/FeedExtractor.java+++ /dev/null@@ -1,17 +0,0 @@-package org.schabi.newpipe.extractor.feed;--import org.schabi.newpipe.extractor.ListExtractor;-import org.schabi.newpipe.extractor.StreamingService;-import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;-import org.schabi.newpipe.extractor.stream.StreamInfoItem;--/**- * This class helps to extract items from lightweight feeds that the services may provide.- * <p>- * YouTube is an example of a service that has this alternative available.- */-public abstract class FeedExtractor extends ListExtractor<StreamInfoItem> {- public FeedExtractor(final StreamingService service, final ListLinkHandler listLinkHandler) {- super(service, listLinkHandler);- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/feed/FeedInfo.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/feed/FeedInfo.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/feed/FeedInfo.javadeleted file mode 100644index 9beb46a23c..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/feed/FeedInfo.java+++ /dev/null@@ -1,62 +0,0 @@-package org.schabi.newpipe.extractor.feed;--import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;-import org.schabi.newpipe.extractor.ListInfo;-import org.schabi.newpipe.extractor.NewPipe;-import org.schabi.newpipe.extractor.StreamingService;-import org.schabi.newpipe.extractor.exceptions.ExtractionException;-import org.schabi.newpipe.extractor.stream.StreamInfoItem;-import org.schabi.newpipe.extractor.utils.ExtractorHelper;--import java.io.IOException;-import java.util.List;--public class FeedInfo extends ListInfo<StreamInfoItem> {-- public FeedInfo(final int serviceId,- final String id,- final String url,- final String originalUrl,- final String name,- final List<String> contentFilter,- final String sortFilter) {- super(serviceId, id, url, originalUrl, name, contentFilter, sortFilter);- }-- public static FeedInfo getInfo(final String url) throws IOException, ExtractionException {- return getInfo(NewPipe.getServiceByUrl(url), url);- }-- public static FeedInfo getInfo(final StreamingService service, final String url)- throws IOException, ExtractionException {- final FeedExtractor extractor = service.getFeedExtractor(url);-- if (extractor == null) {- throw new IllegalArgumentException("Service \"" + service.getServiceInfo().getName()- + "\" doesn't support FeedExtractor.");- }-- extractor.fetchPage();- return getInfo(extractor);- }-- public static FeedInfo getInfo(final FeedExtractor extractor)- throws IOException, ExtractionException {- extractor.fetchPage();-- final int serviceId = extractor.getServiceId();- final String id = extractor.getId();- final String url = extractor.getUrl();- final String originalUrl = extractor.getOriginalUrl();- final String name = extractor.getName();-- final FeedInfo info = new FeedInfo(serviceId, id, url, originalUrl, name, null, null);-- final InfoItemsPage<StreamInfoItem> itemsPage- = ExtractorHelper.getItemsPageOrLogError(info, extractor);- info.setRelatedItems(itemsPage.getItems());- info.setNextPage(itemsPage.getNextPage());-- return info;- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.javadeleted file mode 100644index a714deadb7..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java+++ /dev/null@@ -1,61 +0,0 @@-package org.schabi.newpipe.extractor.playlist;--import org.schabi.newpipe.extractor.Image;-import org.schabi.newpipe.extractor.ListExtractor;-import org.schabi.newpipe.extractor.StreamingService;-import org.schabi.newpipe.extractor.exceptions.ParsingException;-import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;-import org.schabi.newpipe.extractor.stream.Description;-import org.schabi.newpipe.extractor.stream.StreamInfoItem;--import javax.annotation.Nonnull;--import java.util.Collections;-import java.util.List;--public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {-- public PlaylistExtractor(final StreamingService service, final ListLinkHandler linkHandler) {- super(service, linkHandler);- }-- public abstract String getUploaderUrl() throws ParsingException;- public abstract String getUploaderName() throws ParsingException;- @Nonnull- public abstract List<Image> getUploaderAvatars() throws ParsingException;- public abstract boolean isUploaderVerified() throws ParsingException;-- public abstract long getStreamCount() throws ParsingException;-- @Nonnull- public abstract Description getDescription() throws ParsingException;-- @Nonnull- public List<Image> getThumbnails() throws ParsingException {- return Collections.emptyList();- }-- @Nonnull- public List<Image> getBanners() throws ParsingException {- return List.of();- }-- @Nonnull- public String getSubChannelName() throws ParsingException {- return "";- }-- @Nonnull- public String getSubChannelUrl() throws ParsingException {- return "";- }-- @Nonnull- public List<Image> getSubChannelAvatars() throws ParsingException {- return List.of();- }-- public PlaylistInfo.PlaylistType getPlaylistType() throws ParsingException {- return PlaylistInfo.PlaylistType.NORMAL;- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.javadeleted file mode 100644index 74494ccd4c..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java+++ /dev/null@@ -1,285 +0,0 @@-package org.schabi.newpipe.extractor.playlist;--import org.schabi.newpipe.extractor.Image;-import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;-import org.schabi.newpipe.extractor.ListInfo;-import org.schabi.newpipe.extractor.NewPipe;-import org.schabi.newpipe.extractor.Page;-import org.schabi.newpipe.extractor.StreamingService;-import org.schabi.newpipe.extractor.exceptions.ExtractionException;-import org.schabi.newpipe.extractor.exceptions.ParsingException;-import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;-import org.schabi.newpipe.extractor.stream.Description;-import org.schabi.newpipe.extractor.stream.StreamInfoItem;-import org.schabi.newpipe.extractor.utils.ExtractorHelper;--import java.io.IOException;-import java.util.ArrayList;-import java.util.List;--import javax.annotation.Nonnull;--public final class PlaylistInfo extends ListInfo<StreamInfoItem> {-- /**- * Mixes are handled as particular playlists in NewPipeExtractor. {@link PlaylistType#NORMAL} is- * for non-mixes, while other values are for the different types of mixes. The type of a mix- * depends on how its contents are autogenerated.- */- public enum PlaylistType {- /**- * A normal playlist (not a mix)- */- NORMAL,-- /**- * A mix made only of streams related to a particular stream, for example YouTube mixes- */- MIX_STREAM,-- /**- * A mix made only of music streams related to a particular stream, for example YouTube- * music mixes- */- MIX_MUSIC,-- /**- * A mix made only of streams from (or related to) the same channel, for example YouTube- * channel mixes- *- * @deprecated There is currently no service that implements this.- * YouTube removed all playlists with this type around 2024-06- */- @Deprecated- MIX_CHANNEL,-- /**- * A mix made only of streams related to a particular (musical) genre, for example YouTube- * genre mixes- */- MIX_GENRE,- }-- @SuppressWarnings("RedundantThrows")- private PlaylistInfo(final int serviceId, final ListLinkHandler linkHandler, final String name)- throws ParsingException {- super(serviceId, linkHandler, name);- }-- public static PlaylistInfo getInfo(final String url) throws IOException, ExtractionException {- return getInfo(NewPipe.getServiceByUrl(url), url);- }-- public static PlaylistInfo getInfo(final StreamingService service, final String url)- throws IOException, ExtractionException {- final PlaylistExtractor extractor = service.getPlaylistExtractor(url);- extractor.fetchPage();- return getInfo(extractor);- }-- public static InfoItemsPage<StreamInfoItem> getMoreItems(final StreamingService service,- final String url,- final Page page)- throws IOException, ExtractionException {- return service.getPlaylistExtractor(url).getPage(page);- }-- /**- * Get PlaylistInfo from PlaylistExtractor- *- * @param extractor an extractor where fetchPage() was already got called on.- */- public static PlaylistInfo getInfo(final PlaylistExtractor extractor)- throws ExtractionException {-- final PlaylistInfo info = new PlaylistInfo(- extractor.getServiceId(),- extractor.getLinkHandler(),- extractor.getName());- // collect uploader extraction failures until we are sure this is not- // just a playlist without an uploader- final List<Throwable> uploaderParsingErrors = new ArrayList<>();-- try {- info.setOriginalUrl(extractor.getOriginalUrl());- } catch (final Exception e) {- info.addError(e);- }- try {- info.setStreamCount(extractor.getStreamCount());- } catch (final Exception e) {- info.addError(e);- }- try {- info.setDescription(extractor.getDescription());- } catch (final Exception e) {- info.addError(e);- }- try {- info.setThumbnails(extractor.getThumbnails());- } catch (final Exception e) {- info.addError(e);- }- try {- info.setUploaderUrl(extractor.getUploaderUrl());- } catch (final Exception e) {- uploaderParsingErrors.add(e);- }- try {- info.setUploaderName(extractor.getUploaderName());- } catch (final Exception e) {- uploaderParsingErrors.add(e);- }- try {- info.setUploaderAvatars(extractor.getUploaderAvatars());- } catch (final Exception e) {- uploaderParsingErrors.add(e);- }- try {- info.setSubChannelUrl(extractor.getSubChannelUrl());- } catch (final Exception e) {- uploaderParsingErrors.add(e);- }- try {- info.setSubChannelName(extractor.getSubChannelName());- } catch (final Exception e) {- uploaderParsingErrors.add(e);- }- try {- info.setSubChannelAvatars(extractor.getSubChannelAvatars());- } catch (final Exception e) {- uploaderParsingErrors.add(e);- }- try {- info.setBanners(extractor.getBanners());- } catch (final Exception e) {- info.addError(e);- }- try {- info.setPlaylistType(extractor.getPlaylistType());- } catch (final Exception e) {- info.addError(e);- }-- // do not fail if everything but the uploader infos could be collected (TODO better comment)- if (!uploaderParsingErrors.isEmpty()- && (!info.getErrors().isEmpty() || uploaderParsingErrors.size() < 3)) {- info.addAllErrors(uploaderParsingErrors);- }-- final InfoItemsPage<StreamInfoItem> itemsPage- = ExtractorHelper.getItemsPageOrLogError(info, extractor);- info.setRelatedItems(itemsPage.getItems());- info.setNextPage(itemsPage.getNextPage());-- return info;- }-- private String uploaderUrl = "";- private String uploaderName = "";- private String subChannelUrl;- private String subChannelName;- private Description description;- @Nonnull- private List<Image> banners = List.of();- @Nonnull- private List<Image> subChannelAvatars = List.of();- @Nonnull- private List<Image> thumbnails = List.of();- @Nonnull- private List<Image> uploaderAvatars = List.of();- private long streamCount;- private PlaylistType playlistType;-- @Nonnull- public List<Image> getThumbnails() {- return thumbnails;- }-- public void setThumbnails(@Nonnull final List<Image> thumbnails) {- this.thumbnails = thumbnails;- }-- @Nonnull- public List<Image> getBanners() {- return banners;- }-- public void setBanners(@Nonnull final List<Image> banners) {- this.banners = banners;- }-- public String getUploaderUrl() {- return uploaderUrl;- }-- public void setUploaderUrl(final String uploaderUrl) {- this.uploaderUrl = uploaderUrl;- }-- public String getUploaderName() {- return uploaderName;- }-- public void setUploaderName(final String uploaderName) {- this.uploaderName = uploaderName;- }-- @Nonnull- public List<Image> getUploaderAvatars() {- return uploaderAvatars;- }-- public void setUploaderAvatars(@Nonnull final List<Image> uploaderAvatars) {- this.uploaderAvatars = uploaderAvatars;- }-- public String getSubChannelUrl() {- return subChannelUrl;- }-- public void setSubChannelUrl(final String subChannelUrl) {- this.subChannelUrl = subChannelUrl;- }-- public String getSubChannelName() {- return subChannelName;- }-- public void setSubChannelName(final String subChannelName) {- this.subChannelName = subChannelName;- }-- @Nonnull- public List<Image> getSubChannelAvatars() {- return subChannelAvatars;- }-- public void setSubChannelAvatars(@Nonnull final List<Image> subChannelAvatars) {- this.subChannelAvatars = subChannelAvatars;- }-- public long getStreamCount() {- return streamCount;- }-- public void setStreamCount(final long streamCount) {- this.streamCount = streamCount;- }-- public Description getDescription() {- return description;- }-- public void setDescription(final Description description) {- this.description = description;- }-- public PlaylistType getPlaylistType() {- return playlistType;- }-- public void setPlaylistType(final PlaylistType playlistType) {- this.playlistType = playlistType;- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItem.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItem.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItem.javadeleted file mode 100644index 10ff126835..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItem.java+++ /dev/null@@ -1,72 +0,0 @@-package org.schabi.newpipe.extractor.playlist;--import org.schabi.newpipe.extractor.InfoItem;-import org.schabi.newpipe.extractor.stream.Description;--import javax.annotation.Nullable;--public class PlaylistInfoItem extends InfoItem {-- private String uploaderName;- private String uploaderUrl;- private boolean uploaderVerified;- /**- * How many streams this playlist have- */- private long streamCount = 0;- private Description description;- private PlaylistInfo.PlaylistType playlistType;-- public PlaylistInfoItem(final int serviceId, final String url, final String name) {- super(InfoType.PLAYLIST, serviceId, url, name);- }-- public String getUploaderName() {- return uploaderName;- }-- public void setUploaderName(final String uploaderName) {- this.uploaderName = uploaderName;- }-- @Nullable- public String getUploaderUrl() {- return uploaderUrl;- }-- public void setUploaderUrl(@Nullable final String uploaderUrl) {- this.uploaderUrl = uploaderUrl;- }-- public boolean isUploaderVerified() {- return uploaderVerified;- }-- public void setUploaderVerified(final boolean uploaderVerified) {- this.uploaderVerified = uploaderVerified;- }-- public long getStreamCount() {- return streamCount;- }-- public void setStreamCount(final long streamCount) {- this.streamCount = streamCount;- }-- public Description getDescription() {- return description;- }-- public void setDescription(final Description description) {- this.description = description;- }-- public PlaylistInfo.PlaylistType getPlaylistType() {- return playlistType;- }-- public void setPlaylistType(final PlaylistInfo.PlaylistType playlistType) {- this.playlistType = playlistType;- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemExtractor.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemExtractor.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemExtractor.javadeleted file mode 100644index e9c8231069..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemExtractor.java+++ /dev/null@@ -1,53 +0,0 @@-package org.schabi.newpipe.extractor.playlist;--import org.schabi.newpipe.extractor.InfoItemExtractor;-import org.schabi.newpipe.extractor.exceptions.ParsingException;-import org.schabi.newpipe.extractor.stream.Description;--import javax.annotation.Nonnull;--public interface PlaylistInfoItemExtractor extends InfoItemExtractor {-- /**- * Get the uploader name- * @return the uploader name- */- String getUploaderName() throws ParsingException;-- /**- * Get the uploader url- * @return the uploader url- */- String getUploaderUrl() throws ParsingException;-- /**- * Get whether the uploader is verified- * @return whether the uploader is verified- */- boolean isUploaderVerified() throws ParsingException;-- /**- * Get the number of streams- * @return the number of streams- */- long getStreamCount() throws ParsingException;-- /**- * Get the description of the playlist if there is any.- * Otherwise, an {@link Description#EMPTY_DESCRIPTION EMPTY_DESCRIPTION} is returned.- * @return the playlist's description- */- @Nonnull- default Description getDescription() throws ParsingException {- return Description.EMPTY_DESCRIPTION;- }-- /**- * @return the type of this playlist, see {@link PlaylistInfo.PlaylistType} for a description- * of types. If not overridden always returns {@link PlaylistInfo.PlaylistType#NORMAL}.- */- @Nonnull- default PlaylistInfo.PlaylistType getPlaylistType() throws ParsingException {- return PlaylistInfo.PlaylistType.NORMAL;- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemsCollector.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemsCollector.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemsCollector.javadeleted file mode 100644index 0b854a999f..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemsCollector.java+++ /dev/null@@ -1,56 +0,0 @@-package org.schabi.newpipe.extractor.playlist;--import org.schabi.newpipe.extractor.InfoItemsCollector;-import org.schabi.newpipe.extractor.exceptions.ParsingException;--public class PlaylistInfoItemsCollector- extends InfoItemsCollector<PlaylistInfoItem, PlaylistInfoItemExtractor> {-- public PlaylistInfoItemsCollector(final int serviceId) {- super(serviceId);- }-- @Override- public PlaylistInfoItem extract(final PlaylistInfoItemExtractor extractor)- throws ParsingException {- final PlaylistInfoItem resultItem = new PlaylistInfoItem(- getServiceId(), extractor.getUrl(), extractor.getName());-- try {- resultItem.setUploaderName(extractor.getUploaderName());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setUploaderUrl(extractor.getUploaderUrl());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setUploaderVerified(extractor.isUploaderVerified());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setThumbnails(extractor.getThumbnails());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setStreamCount(extractor.getStreamCount());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setDescription(extractor.getDescription());- } catch (final Exception e) {- addError(e);- }- try {- resultItem.setPlaylistType(extractor.getPlaylistType());- } catch (final Exception e) {- addError(e);- }- return resultItem;- }-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.javadeleted file mode 100644index 601359acf6..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java+++ /dev/null@@ -1,72 +0,0 @@-package org.schabi.newpipe.extractor.search;--import org.schabi.newpipe.extractor.InfoItem;-import org.schabi.newpipe.extractor.ListExtractor;-import org.schabi.newpipe.extractor.MetaInfo;-import org.schabi.newpipe.extractor.StreamingService;-import org.schabi.newpipe.extractor.exceptions.ExtractionException;-import org.schabi.newpipe.extractor.exceptions.ParsingException;-import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;--import javax.annotation.Nonnull;-import java.util.List;--public abstract class SearchExtractor extends ListExtractor<InfoItem> {-- public static class NothingFoundException extends ExtractionException {- public NothingFoundException(final String message) {- super(message);- }- }-- public SearchExtractor(final StreamingService service, final SearchQueryHandler linkHandler) {- super(service, linkHandler);- }-- public String getSearchString() {- return getLinkHandler().getSearchString();- }-- /**- * The search suggestion provided by the service.- * <p>- * This method also returns the corrected query if- * {@link SearchExtractor#isCorrectedSearch()} is true.- *- * @return a suggestion to another query, the corrected query, or an empty String.- */- @Nonnull- public abstract String getSearchSuggestion() throws ParsingException;-- @Nonnull- @Override- public SearchQueryHandler getLinkHandler() {- return (SearchQueryHandler) super.getLinkHandler();- }-- @Nonnull- @Override- public String getName() {- return getLinkHandler().getSearchString();- }-- /**- * Tell if the search was corrected by the service (if it's not exactly the search you typed).- * <p>- * Example: on YouTube, if you search for "pewdeipie",- * it will give you results for "pewdiepie", then isCorrectedSearch should return true.- *- * @return whether the results comes from a corrected query or not.- */- public abstract boolean isCorrectedSearch() throws ParsingException;-- /**- * Meta information about the search query.- * <p>- * Example: on YouTube, if you search for "Covid-19",- * there is a box with information from the WHO about Covid-19 and a link to the WHO's website.- * @return additional meta information about the search query- */- @Nonnull- public abstract List<MetaInfo> getMetaInfo() throws ParsingException;-}
youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java
diff --git a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java b/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.javadeleted file mode 100644index f9251da44d..0000000000--- a/youpipe/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java+++ /dev/null@@ -1,113 +0,0 @@-package org.schabi.newpipe.extractor.search;--import org.schabi.newpipe.extractor.InfoItem;-import org.schabi.newpipe.extractor.ListExtractor;-import org.schabi.newpipe.extractor.ListInfo;-import org.schabi.newpipe.extractor.MetaInfo;-import org.schabi.newpipe.extractor.Page;-import org.schabi.newpipe.extractor.StreamingService;-import org.schabi.newpipe.extractor.exceptions.ExtractionException;-import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;-import org.schabi.newpipe.extractor.utils.ExtractorHelper;--import java.io.IOException;-import java.util.List;--import javax.annotation.Nonnull;--public class SearchInfo extends ListInfo<InfoItem> {- private final String searchString;- private String searchSuggestion;- private boolean isCorrectedSearch;- private List<MetaInfo> metaInfo = List
Diff truncated.