Use optional mimetypes on rich document, if available

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2019-05-08 09:27:34 +02:00
parent deffbd8b00
commit 47317967a3
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
4 changed files with 36 additions and 3 deletions

View file

@ -1961,6 +1961,8 @@ public class FileDataStorageManager {
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT, capability.getRichDocuments().getValue());
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST,
TextUtils.join(",", capability.getRichDocumentsMimeTypeList()));
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_OPTIONAL_MIMETYPE_LIST,
TextUtils.join(",", capability.getRichDocumentsOptionalMimeTypeList()));
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING, capability.getRichDocumentsDirectEditing()
.getValue());
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_TEMPLATES, capability.getRichDocumentsTemplatesAvailable()
@ -2132,6 +2134,13 @@ public class FileDataStorageManager {
mimetypes = "";
}
capability.setRichDocumentsMimeTypeList(Arrays.asList(mimetypes.split(",")));
String optionalMimetypes = c.getString(c.getColumnIndex(
ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_OPTIONAL_MIMETYPE_LIST));
if (optionalMimetypes == null) {
optionalMimetypes = "";
}
capability.setRichDocumentsOptionalMimeTypeList(Arrays.asList(optionalMimetypes.split(",")));
}
return capability;
}

View file

@ -31,7 +31,7 @@ import com.owncloud.android.MainApp;
*/
public class ProviderMeta {
public static final String DB_NAME = "filelist";
public static final int DB_VERSION = 45;
public static final int DB_VERSION = 46;
private ProviderMeta() {
// No instance
@ -184,6 +184,8 @@ public class ProviderMeta {
public static final String CAPABILITIES_ACTIVITY = "activity";
public static final String CAPABILITIES_RICHDOCUMENT = "richdocument";
public static final String CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST = "richdocument_mimetype_list";
public static final String CAPABILITIES_RICHDOCUMENT_OPTIONAL_MIMETYPE_LIST =
"richdocument_optional_mimetype_list";
public static final String CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING = "richdocument_direct_editing";
public static final String CAPABILITIES_RICHDOCUMENT_TEMPLATES = "richdocument_direct_templates";

View file

@ -248,8 +248,10 @@ public class FileMenuFilter {
}
private void filterOpenAsRichDocument(List<Integer> toShow, List<Integer> toHide, OCCapability capability) {
String mimeType = mFiles.iterator().next().getMimeType();
if (isSingleFile() && android.os.Build.VERSION.SDK_INT >= RichDocumentsWebView.MINIMUM_API &&
capability.getRichDocumentsMimeTypeList().contains(mFiles.iterator().next().getMimeType()) &&
(capability.getRichDocumentsMimeTypeList().contains(mimeType) ||
capability.getRichDocumentsOptionalMimeTypeList().contains(mimeType)) &&
capability.getRichDocumentsDirectEditing().isTrue()) {
toShow.add(R.id.action_open_file_as_richdocument);
} else {

View file

@ -769,7 +769,8 @@ public class FileContentProvider extends ContentProvider {
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT + INTEGER
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST + TEXT
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING + INTEGER
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_TEMPLATES + " INTEGER );");
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_TEMPLATES + INTEGER
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_OPTIONAL_MIMETYPE_LIST + " TEXT );");
}
private void createUploadsTable(SQLiteDatabase db) {
@ -1926,6 +1927,25 @@ public class FileContentProvider extends ContentProvider {
if (!upgraded) {
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
}
if (oldVersion < 46 && newVersion >= 46) {
Log_OC.i(SQL, "Entering in the #46 add optional mimetypes to capabilities table");
db.beginTransaction();
try {
db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME +
ADD_COLUMN + ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_OPTIONAL_MIMETYPE_LIST
+ " TEXT ");
upgraded = true;
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
if (!upgraded) {
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
}
}
@Override