mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-04-20 03:24:50 +00:00
Autobackup password check, Filesize estimation int overflow fix, Deleting subscriptions part of subgroup fix, License delete confirm dialog, double check pager closed runtimes
This commit is contained in:
parent
47ff2e0c38
commit
096ba54eb1
9 changed files with 54 additions and 14 deletions
|
@ -862,10 +862,14 @@ class Settings : FragmentedStorageFileJson() {
|
|||
|
||||
@FormField(R.string.clear_payment, FieldForm.BUTTON, R.string.deletes_license_keys_from_app, 2)
|
||||
fun clearPayment() {
|
||||
StatePayment.instance.clearLicenses();
|
||||
SettingsActivity.getActivity()?.let {
|
||||
UIDialogs.toast(it, it.getString(R.string.licenses_cleared_might_require_app_restart));
|
||||
it.reloadSettings();
|
||||
SettingsActivity.getActivity()?.let { context ->
|
||||
UIDialogs.showConfirmationDialog(context, "Are you sure you want to delete your license?", {
|
||||
StatePayment.instance.clearLicenses();
|
||||
SettingsActivity.getActivity()?.let {
|
||||
UIDialogs.toast(it, it.getString(R.string.licenses_cleared_might_require_app_restart));
|
||||
it.reloadSettings();
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,6 +71,8 @@ abstract class JSPager<T> : IPager<T> {
|
|||
|
||||
warnIfMainThread("JSPager.getResults");
|
||||
val items = pager.getOrThrow<V8ValueArray>(config, "results", "JSPager");
|
||||
if(items.v8Runtime.isDead || items.v8Runtime.isClosed)
|
||||
throw IllegalStateException("Runtime closed");
|
||||
val newResults = items.toArray()
|
||||
.map { convertResult(it as V8ValueObject) }
|
||||
.toList();
|
||||
|
|
|
@ -22,6 +22,7 @@ class AutomaticBackupDialog(context: Context) : AlertDialog(context) {
|
|||
private lateinit var _buttonCancel: ImageButton;
|
||||
|
||||
private lateinit var _editPassword: EditText;
|
||||
private lateinit var _editPassword2: EditText;
|
||||
|
||||
private lateinit var _inputMethodManager: InputMethodManager;
|
||||
|
||||
|
@ -34,6 +35,7 @@ class AutomaticBackupDialog(context: Context) : AlertDialog(context) {
|
|||
_buttonStop = findViewById(R.id.button_stop);
|
||||
_buttonStart = findViewById(R.id.button_start);
|
||||
_editPassword = findViewById(R.id.edit_password);
|
||||
_editPassword2 = findViewById(R.id.edit_password2);
|
||||
|
||||
_inputMethodManager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager;
|
||||
|
||||
|
@ -52,6 +54,13 @@ class AutomaticBackupDialog(context: Context) : AlertDialog(context) {
|
|||
}
|
||||
|
||||
_buttonStart.setOnClickListener {
|
||||
val p1 = _editPassword.text.toString();
|
||||
val p2 = _editPassword2.text.toString();
|
||||
if(!(p1?.equals(p2) ?: false)) {
|
||||
UIDialogs.toast(context, "Password fields do not match, confirm that you typed it correctly.");
|
||||
return@setOnClickListener;
|
||||
}
|
||||
|
||||
val pbytes = _editPassword.text.toString().toByteArray();
|
||||
if(pbytes.size < 4 || pbytes.size > 32) {
|
||||
UIDialogs.toast(context, "Password needs to be atleast 4 bytes long and smaller than 32 bytes", false);
|
||||
|
|
|
@ -253,7 +253,7 @@ class SubscriptionGroupFragment : MainFragment() {
|
|||
if(g.urls.isEmpty() && g.image == null) {
|
||||
//Obtain image
|
||||
for(sub in it) {
|
||||
val sub = StateSubscriptions.instance.getSubscription(sub);
|
||||
val sub = StateSubscriptions.instance.getSubscription(sub) ?: StateSubscriptions.instance.getSubscriptionOther(sub);
|
||||
if(sub != null && sub.channel.thumbnail != null) {
|
||||
g.image = ImageVariable.fromUrl(sub.channel.thumbnail!!);
|
||||
g.image?.setImageView(_imageGroup);
|
||||
|
@ -308,8 +308,10 @@ class SubscriptionGroupFragment : MainFragment() {
|
|||
|
||||
if(group != null) {
|
||||
val urls = group.urls.toList();
|
||||
val subs = StateSubscriptions.instance.getSubscriptions().map { it.channel }
|
||||
_enabledCreators.addAll(subs.filter { urls.contains(it.url) });
|
||||
val subs = urls.map {
|
||||
(StateSubscriptions.instance.getSubscription(it) ?: StateSubscriptions.instance.getSubscriptionOther(it))?.channel
|
||||
}.filterNotNull();
|
||||
_enabledCreators.addAll(subs);
|
||||
}
|
||||
updateMeta();
|
||||
filterCreators();
|
||||
|
|
|
@ -191,21 +191,21 @@ class VideoHelper {
|
|||
}
|
||||
|
||||
|
||||
fun estimateSourceSize(source: IVideoSource?): Int {
|
||||
fun estimateSourceSize(source: IVideoSource?): Long {
|
||||
if(source == null) return 0;
|
||||
if(source is IVideoSource) {
|
||||
if(source.bitrate ?: 0 <= 0 || source.duration.toInt() == 0)
|
||||
return 0;
|
||||
return (source.duration / 8).toInt() * source.bitrate!!;
|
||||
return (source.duration / 8) * source.bitrate!!;
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
fun estimateSourceSize(source: IAudioSource?): Int {
|
||||
fun estimateSourceSize(source: IAudioSource?): Long {
|
||||
if(source == null) return 0;
|
||||
if(source is IAudioSource) {
|
||||
if(source.bitrate <= 0 || source.duration?.toInt() ?: 0 == 0)
|
||||
return 0;
|
||||
return (source.duration!! / 8).toInt() * source.bitrate;
|
||||
return (source.duration!! / 8) * source.bitrate;
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
|
|
|
@ -110,6 +110,15 @@ class StateSubscriptionGroups {
|
|||
}
|
||||
}
|
||||
|
||||
fun hasSubscriptionGroup(url: String): Boolean {
|
||||
val groups = getSubscriptionGroups();
|
||||
for(group in groups){
|
||||
if(group.urls.contains(url))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
fun getSyncSubscriptionGroupsPackageString(): String{
|
||||
return Json.encodeToString(
|
||||
|
|
|
@ -202,13 +202,13 @@ class StateSubscriptions {
|
|||
return _subscriptionOthers.findItem { it.isChannel(url)};
|
||||
}
|
||||
}
|
||||
fun getSubscriptionOtherOrCreate(url: String) : Subscription {
|
||||
fun getSubscriptionOtherOrCreate(url: String, name: String? = null, thumbnail: String? = null) : Subscription {
|
||||
synchronized(_subscriptionOthers) {
|
||||
val sub = getSubscriptionOther(url);
|
||||
if(sub == null) {
|
||||
val newSub = Subscription(SerializedChannel(PlatformID.NONE, url, null, null, 0, null, url, mapOf()));
|
||||
val newSub = Subscription(SerializedChannel(PlatformID.NONE, name ?: url, thumbnail, null, 0, null, url, mapOf()));
|
||||
newSub.isOther = true;
|
||||
_subscriptions.save(newSub);
|
||||
_subscriptionOthers.save(newSub);
|
||||
return newSub;
|
||||
}
|
||||
else return sub;
|
||||
|
@ -295,6 +295,9 @@ class StateSubscriptions {
|
|||
onSubscriptionsChanged.emit(getSubscriptions(), false);
|
||||
if(isUserAction)
|
||||
_subscriptionsRemoved.setAndSave(sub.channel.url, OffsetDateTime.now());
|
||||
|
||||
if(StateSubscriptionGroups.instance.hasSubscriptionGroup(sub.channel.url))
|
||||
getSubscriptionOtherOrCreate(sub.channel.url, sub.channel.name, sub.channel.thumbnail);
|
||||
}
|
||||
return sub;
|
||||
}
|
||||
|
|
|
@ -71,6 +71,16 @@
|
|||
android:singleLine="true"
|
||||
android:inputType="textPassword"
|
||||
android:hint="@string/backup_password" />
|
||||
<EditText
|
||||
android:id="@+id/edit_password2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginLeft="30dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginRight="30dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:inputType="textPassword"
|
||||
android:hint="@string/repeat_password" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -180,6 +180,7 @@
|
|||
<string name="set_a_password_for_your_daily_backup">Set a password for your daily backup</string>
|
||||
<string name="set_a_password_used_to_encrypt_your_daily_backup_that_is_written_to_external_storage">Set a password used to encrypt your daily backup that is written to external storage.</string>
|
||||
<string name="backup_password">Backup Password</string>
|
||||
<string name="repeat_password">Repeat Password</string>
|
||||
<string name="restore_from_automatic_backup">Restore from Automatic Backup</string>
|
||||
<string name="it_appears_an_automatic_backup_exists_on_your_device_if_you_would_like_to_restore_enter_your_backup_password">It appears an automatic backup exists on your device, if you would like to restore, enter your backup password.</string>
|
||||
<string name="restore">Restore</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue