Skip to content
Snippets Groups Projects
Commit dd0ad19f authored by Kelvin's avatar Kelvin
Browse files

NewLine subs import, fix no-recent video subscriptions

parent 430625d2
No related branches found
No related tags found
No related merge requests found
...@@ -92,6 +92,26 @@ ...@@ -92,6 +92,26 @@
<data android:host="*" /> <data android:host="*" />
<data android:scheme="file" /> <data android:scheme="file" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter android:autoVerify="true">
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.VIEW" />
<data android:host="*" />
<data android:scheme="content" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter android:autoVerify="true">
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.VIEW" />
<data android:host="*" />
<data android:scheme="file" />
<data android:mimeType="application/zip" /> <data android:mimeType="application/zip" />
</intent-filter> </intent-filter>
<intent-filter android:autoVerify="true"> <intent-filter android:autoVerify="true">
......
...@@ -591,6 +591,9 @@ class MainActivity : AppCompatActivity, IWithResultLauncher { ...@@ -591,6 +591,9 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
StateBackup.importZipBytes(this, lifecycleScope, data); StateBackup.importZipBytes(this, lifecycleScope, data);
return true; return true;
} }
else if(file.lowercase().endsWith(".txt") || mime == "text/plain") {
return handleUnknownText(String(data));
}
return false; return false;
} }
fun handleFile(file: String): Boolean { fun handleFile(file: String): Boolean {
...@@ -608,6 +611,9 @@ class MainActivity : AppCompatActivity, IWithResultLauncher { ...@@ -608,6 +611,9 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
StateBackup.importZipBytes(this, lifecycleScope, readSharedFile(file)); StateBackup.importZipBytes(this, lifecycleScope, readSharedFile(file));
return true; return true;
} }
else if(file.lowercase().endsWith(".txt")) {
return handleUnknownText(String(readSharedFile(file)));
}
return false; return false;
} }
fun handleReconstruction(recon: String) { fun handleReconstruction(recon: String) {
...@@ -633,6 +639,20 @@ class MainActivity : AppCompatActivity, IWithResultLauncher { ...@@ -633,6 +639,20 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
} }
} }
fun handleUnknownText(text: String): Boolean {
try {
if(text.startsWith("@/Subscription") || text.startsWith("Subscriptions")) {
val lines = text.split("\n").map { it.trim() }.drop(1).filter { it.isNotEmpty() };
navigate(_fragImportSubscriptions, lines);
return true;
}
}
catch(ex: Throwable) {
Logger.e(TAG, ex.message, ex);
UIDialogs.showGeneralErrorDialog(this, getString(R.string.failed_to_parse_text_file), ex);
}
return false;
}
fun handleUnknownJson(name: String?, json: String): Boolean { fun handleUnknownJson(name: String?, json: String): Boolean {
val context = this; val context = this;
......
...@@ -210,7 +210,7 @@ class ImportSubscriptionsFragment : MainFragment() { ...@@ -210,7 +210,7 @@ class ImportSubscriptionsFragment : MainFragment() {
companion object { companion object {
val TAG = "ImportSubscriptionsFragment"; val TAG = "ImportSubscriptionsFragment";
private const val MAXIMUM_BATCH_SIZE = 90; private const val MAXIMUM_BATCH_SIZE = 100;
fun newInstance() = ImportSubscriptionsFragment().apply {} fun newInstance() = ImportSubscriptionsFragment().apply {}
} }
} }
\ No newline at end of file
...@@ -42,9 +42,13 @@ class SmartSubscriptionAlgorithm( ...@@ -42,9 +42,13 @@ class SmartSubscriptionAlgorithm(
if(sub.shouldFetchPosts()) ResultCapabilities.TYPE_POSTS else null, if(sub.shouldFetchPosts()) ResultCapabilities.TYPE_POSTS else null,
if(sub.shouldFetchLiveStreams()) ResultCapabilities.TYPE_LIVE else null if(sub.shouldFetchLiveStreams()) ResultCapabilities.TYPE_LIVE else null
).filterNotNull().filter { capabilities.hasType(it) }; ).filterNotNull().filter { capabilities.hasType(it) };
return@flatMap types.map {
SubscriptionTask(client, sub, url, it); if(!types.isEmpty())
}; return@flatMap types.map {
SubscriptionTask(client, sub, url, it);
};
else
listOf(SubscriptionTask(client, sub, url, ResultCapabilities.TYPE_VIDEOS, true))
} }
}; };
}; };
......
...@@ -57,7 +57,7 @@ abstract class SubscriptionsTaskFetchAlgorithm( ...@@ -57,7 +57,7 @@ abstract class SubscriptionsTaskFetchAlgorithm(
for(clientTasks in tasksGrouped) { for(clientTasks in tasksGrouped) {
val clientTaskCount = clientTasks.value.filter { !it.fromCache }.size; val clientTaskCount = clientTasks.value.filter { !it.fromCache }.size;
val clientCacheCount = clientTasks.value.size - clientTaskCount; val clientCacheCount = clientTasks.value.size - clientTaskCount;
if(clientCacheCount > 0 && StateApp.instance.contextOrNull?.let { it is MainActivity && it.isFragmentActive<SubscriptionsFeedFragment>() } == true) { if(clientCacheCount > 0 && clientTaskCount > 0 && StateApp.instance.contextOrNull?.let { it is MainActivity && it.isFragmentActive<SubscriptionsFeedFragment>() } == true) {
UIDialogs.toast("[${clientTasks.key.name}] only updating ${clientTaskCount} most urgent channels (rqs). (${clientCacheCount} cached)"); UIDialogs.toast("[${clientTasks.key.name}] only updating ${clientTaskCount} most urgent channels (rqs). (${clientCacheCount} cached)");
} }
} }
......
...@@ -435,6 +435,7 @@ ...@@ -435,6 +435,7 @@
<string name="unknown_url_format">Unknown url format</string> <string name="unknown_url_format">Unknown url format</string>
<string name="failed_to_handle_file">Failed to handle file</string> <string name="failed_to_handle_file">Failed to handle file</string>
<string name="unknown_reconstruction_type">Unknown reconstruction type</string> <string name="unknown_reconstruction_type">Unknown reconstruction type</string>
<string name="failed_to_parse_text_file">Failed to parse text file</string>
<string name="failed_to_parse_newpipe_subscriptions">Failed to parse NewPipe Subscriptions</string> <string name="failed_to_parse_newpipe_subscriptions">Failed to parse NewPipe Subscriptions</string>
<string name="failed_to_generate_qr_code">Failed to generate QR code</string> <string name="failed_to_generate_qr_code">Failed to generate QR code</string>
<string name="share_text">Share Text</string> <string name="share_text">Share Text</string>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment