0
0
Fork 0
mirror of https://github.com/YTVanced/Integrations synced 2024-11-30 15:13:03 +00:00

add toast for failed exporting

This commit is contained in:
caneleex 2021-08-03 16:38:38 +02:00
parent 82c4847b7f
commit d15fa18bb5
3 changed files with 7 additions and 3 deletions

View file

@ -301,11 +301,13 @@ public class SponsorBlockPreferenceFragment extends PreferenceFragment implement
{
EditTextPreference preference = new EditTextPreference(context);
Context applicationContext = context.getApplicationContext();
preference.setTitle(str("settings_ie"));
preference.setSummary(str("settings_ie_sum"));
preference.setText(SponsorBlockUtils.exportSettings());
preference.setText(SponsorBlockUtils.exportSettings(applicationContext));
preference.setOnPreferenceChangeListener((preference1, newValue) -> {
SponsorBlockUtils.importSettings((String) newValue, context.getApplicationContext());
SponsorBlockUtils.importSettings((String) newValue, applicationContext);
return false;
});
screen.addPreference(preference);

View file

@ -604,7 +604,7 @@ public abstract class SponsorBlockUtils {
}
}
public static String exportSettings() {
public static String exportSettings(Context context) {
try {
JSONObject json = new JSONObject();
@ -636,6 +636,7 @@ public abstract class SponsorBlockUtils {
return json.toString();
}
catch (Exception ex) {
Toast.makeText(context, str("settings_export_failed"), Toast.LENGTH_SHORT).show();
ex.printStackTrace();
return "";
}

View file

@ -161,6 +161,7 @@
<string name="settings_ie_sum">This is your entire configuration that is applicable in the desktop extension in JSON. This includes your userID, so be sure to share this wisely.</string>
<string name="settings_import_successful">Settings were successfully imported</string>
<string name="settings_import_failed">Failed to import settings</string>
<string name="settings_export_failed">Failed to export settings</string>
<string name="segments_sponsor">Sponsor</string>
<string name="segments_sponsor_sum">Paid promotion, paid referrals and direct advertisements</string>
<string name="segments_intermission">Intermission/Intro Animation</string>