diff --git a/app/src/main/java/com/kanedias/vanilla/audiotag/PluginService.java b/app/src/main/java/com/kanedias/vanilla/audiotag/PluginService.java
index 648fecb..33dd187 100644
--- a/app/src/main/java/com/kanedias/vanilla/audiotag/PluginService.java
+++ b/app/src/main/java/com/kanedias/vanilla/audiotag/PluginService.java
@@ -44,9 +44,11 @@
import org.jaudiotagger.audio.exceptions.ReadOnlyFileException;
import org.jaudiotagger.audio.generic.Utils;
import org.jaudiotagger.tag.*;
+import org.jaudiotagger.tag.id3.AbstractID3v2Tag;
import org.jaudiotagger.tag.id3.valuepair.ImageFormats;
import org.jaudiotagger.tag.images.AndroidArtwork;
import org.jaudiotagger.tag.images.Artwork;
+import org.jaudiotagger.tag.reference.ID3V2Version;
import org.jaudiotagger.tag.reference.PictureTypes;
import java.io.File;
@@ -253,6 +255,19 @@ public boolean loadFile() {
return true;
}
+ /**
+ * upgrades ID3v2.x tag to ID3v2.4 for loaded file.
+ * Call this method only if you know exactly that file contains ID3 tag.
+ */
+ public void upgradeID3v2() {
+ mTag = mAudioFile.convertID3Tag((AbstractID3v2Tag) mTag, ID3V2Version.ID3_V24);
+ mAudioFile.setTag(mTag);
+ writeFile();
+ }
+
+ /**
+ * Writes file to backing filesystem provider, this may be either SAF-managed sdcard or internal storage.
+ */
public void writeFile() {
if (SafUtils.isSafNeeded(mAudioFile.getFile())) {
if (mPrefs.contains(PREF_SDCARD_URI)) {
diff --git a/app/src/main/java/com/kanedias/vanilla/audiotag/TagEditActivity.java b/app/src/main/java/com/kanedias/vanilla/audiotag/TagEditActivity.java
index 42cd1a0..973b9fe 100644
--- a/app/src/main/java/com/kanedias/vanilla/audiotag/TagEditActivity.java
+++ b/app/src/main/java/com/kanedias/vanilla/audiotag/TagEditActivity.java
@@ -17,11 +17,12 @@
package com.kanedias.vanilla.audiotag;
import android.app.Activity;
+import android.app.AlertDialog;
import android.content.ComponentName;
+import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
-import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.support.annotation.NonNull;
@@ -43,6 +44,7 @@
import org.jaudiotagger.tag.FieldDataInvalidException;
import org.jaudiotagger.tag.FieldKey;
import org.jaudiotagger.tag.Tag;
+import org.jaudiotagger.tag.id3.ID3v22Tag;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
import static com.kanedias.vanilla.plugins.PluginConstants.*;
@@ -82,6 +84,7 @@ public void onServiceConnected(ComponentName name, IBinder service) {
mService = ((PluginService.PluginBinder) service).getService();
mTag = mService.getTag();
fillInitialValues();
+ miscellaneousChecks();
}
@Override
@@ -203,6 +206,27 @@ private void fillInitialValues() {
mAlbumEdit.setText(mTag.getFirst(FieldKey.ALBUM));
}
+ /**
+ * Miscellaneous checks, e.g. re-tag requests etc.
+ */
+ private void miscellaneousChecks() {
+ // check we need a re-tag
+ if (mTag instanceof ID3v22Tag) {
+ new AlertDialog.Builder(this)
+ .setTitle(R.string.re_tag)
+ .setMessage(R.string.id3_v22_to_v24)
+ .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ mService.upgradeID3v2();
+ mTag = mService.getTag(); // tag was updated, refresh it from service
+ }
+ })
+ .setNegativeButton(android.R.string.cancel, null)
+ .show();
+ }
+ }
+
/**
* We're the good guys, we catch it back from {@link PluginUtils#checkAndRequestPermissions(Activity, String)} here.
* So, if user declined our request, just close the activity entirely.
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index cf0afae..244cfc2 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -11,4 +11,6 @@
File written successfully!
Invalid tag requested
Invalid artwork provided
+ Re-tag
+ Do you want to re-tag ID3 v2.2 to v2.4 in this file for better compatibility?