mirror of
https://github.com/nextcloud/android.git
synced 2024-11-22 21:25:35 +03:00
Use optional mimetypes on rich document, if available
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
parent
deffbd8b00
commit
47317967a3
4 changed files with 36 additions and 3 deletions
|
@ -1961,6 +1961,8 @@ public class FileDataStorageManager {
|
||||||
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT, capability.getRichDocuments().getValue());
|
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT, capability.getRichDocuments().getValue());
|
||||||
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST,
|
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST,
|
||||||
TextUtils.join(",", capability.getRichDocumentsMimeTypeList()));
|
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()
|
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING, capability.getRichDocumentsDirectEditing()
|
||||||
.getValue());
|
.getValue());
|
||||||
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_TEMPLATES, capability.getRichDocumentsTemplatesAvailable()
|
cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_TEMPLATES, capability.getRichDocumentsTemplatesAvailable()
|
||||||
|
@ -2132,6 +2134,13 @@ public class FileDataStorageManager {
|
||||||
mimetypes = "";
|
mimetypes = "";
|
||||||
}
|
}
|
||||||
capability.setRichDocumentsMimeTypeList(Arrays.asList(mimetypes.split(",")));
|
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;
|
return capability;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import com.owncloud.android.MainApp;
|
||||||
*/
|
*/
|
||||||
public class ProviderMeta {
|
public class ProviderMeta {
|
||||||
public static final String DB_NAME = "filelist";
|
public static final String DB_NAME = "filelist";
|
||||||
public static final int DB_VERSION = 45;
|
public static final int DB_VERSION = 46;
|
||||||
|
|
||||||
private ProviderMeta() {
|
private ProviderMeta() {
|
||||||
// No instance
|
// No instance
|
||||||
|
@ -184,6 +184,8 @@ public class ProviderMeta {
|
||||||
public static final String CAPABILITIES_ACTIVITY = "activity";
|
public static final String CAPABILITIES_ACTIVITY = "activity";
|
||||||
public static final String CAPABILITIES_RICHDOCUMENT = "richdocument";
|
public static final String CAPABILITIES_RICHDOCUMENT = "richdocument";
|
||||||
public static final String CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST = "richdocument_mimetype_list";
|
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_DIRECT_EDITING = "richdocument_direct_editing";
|
||||||
public static final String CAPABILITIES_RICHDOCUMENT_TEMPLATES = "richdocument_direct_templates";
|
public static final String CAPABILITIES_RICHDOCUMENT_TEMPLATES = "richdocument_direct_templates";
|
||||||
|
|
||||||
|
|
|
@ -248,8 +248,10 @@ public class FileMenuFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void filterOpenAsRichDocument(List<Integer> toShow, List<Integer> toHide, OCCapability capability) {
|
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 &&
|
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()) {
|
capability.getRichDocumentsDirectEditing().isTrue()) {
|
||||||
toShow.add(R.id.action_open_file_as_richdocument);
|
toShow.add(R.id.action_open_file_as_richdocument);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -769,7 +769,8 @@ public class FileContentProvider extends ContentProvider {
|
||||||
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT + INTEGER
|
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT + INTEGER
|
||||||
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST + TEXT
|
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_MIMETYPE_LIST + TEXT
|
||||||
+ ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING + INTEGER
|
+ 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) {
|
private void createUploadsTable(SQLiteDatabase db) {
|
||||||
|
@ -1926,6 +1927,25 @@ public class FileContentProvider extends ContentProvider {
|
||||||
if (!upgraded) {
|
if (!upgraded) {
|
||||||
Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion));
|
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
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue