Fix dedup in subscriptions feed, Download change directory no longer crashes, Allow uppercase letters in email for payment, Fix developer mode not enabling

This commit is contained in:
Kelvin 2023-10-18 20:11:20 +02:00
parent f4370c1bfd
commit 2067561c09
8 changed files with 31 additions and 23 deletions

View File

@ -52,6 +52,16 @@ class SettingsActivity : AppCompatActivity(), IWithResultLauncher {
startActivity(Intent(this, DeveloperActivity::class.java)); startActivity(Intent(this, DeveloperActivity::class.java));
} }
_lastActivity = this;
reloadSettings();
}
fun reloadSettings() {
_loader.start();
_form.fromObject(lifecycleScope, Settings.instance) {
_loader.stop();
var devCounter = 0; var devCounter = 0;
_form.findField("code")?.assume<ReadOnlyTextField>()?.setOnClickListener { _form.findField("code")?.assume<ReadOnlyTextField>()?.setOnClickListener {
devCounter++; devCounter++;
@ -63,15 +73,6 @@ class SettingsActivity : AppCompatActivity(), IWithResultLauncher {
UIDialogs.toast(this, "You are now in developer mode"); UIDialogs.toast(this, "You are now in developer mode");
} }
}; };
_lastActivity = this;
reloadSettings();
}
fun reloadSettings() {
_loader.start();
_form.fromObject(lifecycleScope, Settings.instance) {
_loader.stop();
}; };
} }

View File

@ -25,7 +25,8 @@ class DedupContentPager : IPager<IPlatformContent>, IAsyncPager<IPlatformContent
_currentResults = dedupResults(_basePager.getResults()); _currentResults = dedupResults(_basePager.getResults());
} }
override fun hasMorePages(): Boolean = _basePager.hasMorePages(); override fun hasMorePages(): Boolean =
_basePager.hasMorePages();
override fun nextPage() { override fun nextPage() {
_basePager.nextPage() _basePager.nextPage()
_currentResults = dedupResults(_basePager.getResults()); _currentResults = dedupResults(_basePager.getResults());

View File

@ -7,7 +7,7 @@ import java.util.stream.IntStream
* A PlatformContent MultiPager that orders the results of a page based on the datetime of a content item * A PlatformContent MultiPager that orders the results of a page based on the datetime of a content item
*/ */
class MultiChronoContentPager : MultiPager<IPlatformContent> { class MultiChronoContentPager : MultiPager<IPlatformContent> {
constructor(pagers : Array<IPager<IPlatformContent>>, allowFailure: Boolean = false) : super(pagers.map { it }.toList(), allowFailure) {} constructor(pagers : Array<IPager<IPlatformContent>>, allowFailure: Boolean = false, pageSize: Int = 9) : super(pagers.map { it }.toList(), allowFailure, pageSize) {}
@Synchronized @Synchronized
override fun selectItemIndex(options: Array<SelectionOption<IPlatformContent>>): Int { override fun selectItemIndex(options: Array<SelectionOption<IPlatformContent>>): Int {

View File

@ -16,7 +16,7 @@ abstract class MultiPager<T> : IPager<T> {
protected val _subSinglePagers : MutableList<SingleItemPager<T>>; protected val _subSinglePagers : MutableList<SingleItemPager<T>>;
protected val _failedPagers: ArrayList<IPager<T>> = arrayListOf(); protected val _failedPagers: ArrayList<IPager<T>> = arrayListOf();
private val _pageSize : Int = 9; private var _pageSize : Int = 9;
private var _didInitialize = false; private var _didInitialize = false;
@ -27,7 +27,8 @@ abstract class MultiPager<T> : IPager<T> {
val totalPagers: Int get() = _pagers.size; val totalPagers: Int get() = _pagers.size;
constructor(pagers : List<IPager<T>>, allowFailure: Boolean = false) { constructor(pagers : List<IPager<T>>, allowFailure: Boolean = false, pageSize: Int = 9) {
this._pageSize = pageSize;
this.allowFailure = allowFailure; this.allowFailure = allowFailure;
_pagers = pagers.toMutableList(); _pagers = pagers.toMutableList();
_subSinglePagers = _pagers.map { SingleItemPager(it) }.toMutableList(); _subSinglePagers = _pagers.map { SingleItemPager(it) }.toMutableList();

View File

@ -91,7 +91,7 @@ class StateApp {
onChanged?.invoke(getExternalGeneralDirectory(context)); onChanged?.invoke(getExternalGeneralDirectory(context));
} }
else else
StateApp.instance.scopeOrNull?.launch(Dispatchers.Main) { scopeOrNull?.launch(Dispatchers.Main) {
UIDialogs.toast("Failed to gain access to\n [${it?.lastPathSegment}]"); UIDialogs.toast("Failed to gain access to\n [${it?.lastPathSegment}]");
}; };
}; };
@ -103,10 +103,14 @@ class StateApp {
return null; return null;
} }
fun changeExternalDownloadDirectory(context: IWithResultLauncher, onChanged: ((DocumentFile?)->Unit)? = null) { fun changeExternalDownloadDirectory(context: IWithResultLauncher, onChanged: ((DocumentFile?)->Unit)? = null) {
scopeOrNull?.launch(Dispatchers.Main) {
UIDialogs.toast("External download directory not yet used by export (WIP)");
};
if(context is Context) if(context is Context)
requestDirectoryAccess(context, "Download Exports", "This directory is used to export downloads to for external usage.", null) { requestDirectoryAccess(context, "Download Exports", "This directory is used to export downloads to for external usage.", null) {
if(it != null) if(it != null)
context.contentResolver.takePersistableUriPermission(it, Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION.or(Intent.FLAG_GRANT_WRITE_URI_PERMISSION.or(Intent.FLAG_GRANT_READ_URI_PERMISSION))); context.contentResolver.takePersistableUriPermission(it, Intent.FLAG_GRANT_WRITE_URI_PERMISSION.or(Intent.FLAG_GRANT_READ_URI_PERMISSION));
if(it != null && isValidStorageUri(context, it)) { if(it != null && isValidStorageUri(context, it)) {
Logger.i(TAG, "Changed external download directory: ${it}"); Logger.i(TAG, "Changed external download directory: ${it}");
Settings.instance.storage.storage_general = it.toString(); Settings.instance.storage.storage_general = it.toString();

View File

@ -219,13 +219,13 @@ class StateSubscriptions {
} }
} }
fun getSubscriptionsFeed(allowFailure: Boolean = false): MultiChronoContentPager { fun getSubscriptionsFeed(allowFailure: Boolean = false): IPager<IPlatformContent> {
val result = getSubscriptionsFeedWithExceptions(allowFailure, true); val result = getSubscriptionsFeedWithExceptions(allowFailure, true);
if(result.second.any()) if(result.second.any())
throw result.second.first(); throw result.second.first();
return result.first; return result.first;
} }
fun getSubscriptionsFeedWithExceptions(allowFailure: Boolean = false, withCacheFallback: Boolean = false, cacheScope: CoroutineScope? = null, onProgress: ((Int, Int)->Unit)? = null, onNewCacheHit: ((Subscription, IPlatformContent)->Unit)? = null): Pair<MultiChronoContentPager, List<Throwable>> { fun getSubscriptionsFeedWithExceptions(allowFailure: Boolean = false, withCacheFallback: Boolean = false, cacheScope: CoroutineScope? = null, onProgress: ((Int, Int)->Unit)? = null, onNewCacheHit: ((Subscription, IPlatformContent)->Unit)? = null): Pair<IPager<IPlatformContent>, List<Throwable>> {
val subsPager: Array<IPager<IPlatformContent>>; val subsPager: Array<IPager<IPlatformContent>>;
val exs: ArrayList<Throwable> = arrayListOf(); val exs: ArrayList<Throwable> = arrayListOf();
@ -343,9 +343,10 @@ class StateSubscriptions {
throw exs.first(); throw exs.first();
Logger.i(TAG, "Subscription pager with ${subsPager.size} channels"); Logger.i(TAG, "Subscription pager with ${subsPager.size} channels");
val pager = MultiChronoContentPager(subsPager, allowFailure); val pager = MultiChronoContentPager(subsPager, allowFailure, 15);
pager.initialize(); pager.initialize();
return Pair(pager, exs); //return Pair(pager, exs);
return Pair(DedupContentPager(pager), exs);
} }
//New Migration //New Migration

@ -1 +1 @@
Subproject commit 1c34bb016378805ca24883ed55573dcd862309cf Subproject commit eba1bb5d2ccf438a2f025a204d2d443e4b76b144

@ -1 +1 @@
Subproject commit 9e589c231187b02a9922f55a962add0a688d28cd Subproject commit 2c608e7eddb742a918b304e3c52888206275f642