From 403a3e062c0b8faaf0e96c68eacb6a4945e574ee Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Tue, 7 May 2019 17:00:22 +0200 Subject: [PATCH] Use product name on rich document, if available use placeholder for string reset to master-snapshot fix analysis warning use new translatable string use var vor qa flavor too Signed-off-by: tobiasKaminsky Signed-off-by: Andy Scherzinger --- build.gradle | 9 ++++---- scripts/analysis/analysis-wrapper.sh | 4 ++-- .../datamodel/FileDataStorageManager.java | 3 +++ .../com/owncloud/android/db/ProviderMeta.java | 3 ++- .../android/files/FileMenuFilter.java | 21 +++++++++++++++---- .../providers/FileContentProvider.java | 21 ++++++++++++++++++- src/main/res/menu/file_actions_menu.xml | 2 +- src/main/res/values/strings.xml | 2 +- 8 files changed, 51 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 7dc2e20de7..7c8308eaa9 100644 --- a/build.gradle +++ b/build.gradle @@ -48,6 +48,7 @@ configurations.all { ext { jacocoVersion = "0.8.2" + androidLibraryVersion = "master-SNAPSHOT" travisBuild = System.getenv("TRAVIS") == "true" @@ -236,10 +237,10 @@ dependencies { // dependencies for app building implementation 'androidx.multidex:multidex:2.0.1' // implementation project('nextcloud-android-library') - genericImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT' - gplayImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT' - versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT' - qaImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT' + genericImplementation "com.github.nextcloud:android-library:$androidLibraryVersion" + gplayImplementation "com.github.nextcloud:android-library:$androidLibraryVersion" + versionDevImplementation "com.github.nextcloud:android-library:$androidLibraryVersion" + qaImplementation 'com.github.nextcloud:android-library:$androidLibraryVersion' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'com.google.android.material:material:1.0.0' diff --git a/scripts/analysis/analysis-wrapper.sh b/scripts/analysis/analysis-wrapper.sh index 427a92d477..8f93b0a8b7 100755 --- a/scripts/analysis/analysis-wrapper.sh +++ b/scripts/analysis/analysis-wrapper.sh @@ -55,10 +55,10 @@ else # check library, only if base branch is master baseBranch=$(scripts/analysis/getBranchBase.sh $1 $2 $7 | tr -d "\"") - if [ $baseBranch = "master" -a $(grep "android-library:master" build.gradle -c) -ne 4 ]; then + if [ $baseBranch = "master" -a $(grep "androidLibraryVersion = \"master-SNAPSHOT\"" build.gradle -c) -ne 1 ]; then checkLibraryMessage="

Android-library is not set to master branch in build.gradle

" checkLibrary=1 - elif [ $baseBranch != "master" -a $baseBranch = $stableBranch -a $(grep "android-library:.*SNAPSHOT" build.gradle -c) -ne 0 ]; then + elif [ $baseBranch != "master" -a $baseBranch = $stableBranch -a $(grep "androidLibraryVersion.*SNAPSHOT" build.gradle -c) -ne 0 ]; then checkLibraryMessage="

Android-library is set to a SNAPSHOT in build.gradle

" checkLibrary=1 else diff --git a/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java index 0fb9b3f8d5..fd8e755b92 100644 --- a/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -1969,6 +1969,7 @@ public class FileDataStorageManager { .getValue()); cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_TEMPLATES, capability.getRichDocumentsTemplatesAvailable() .getValue()); + cv.put(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME, capability.getRichDocumentsProductName()); if (capabilityExists(account.name)) { if (getContentResolver() != null) { @@ -2146,6 +2147,8 @@ public class FileDataStorageManager { optionalMimetypes = ""; } capability.setRichDocumentsOptionalMimeTypeList(Arrays.asList(optionalMimetypes.split(","))); + capability.setRichDocumentsProductName( + c.getString(c.getColumnIndex(ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME))); } return capability; } diff --git a/src/main/java/com/owncloud/android/db/ProviderMeta.java b/src/main/java/com/owncloud/android/db/ProviderMeta.java index b291a1c3f4..bd01686f9d 100644 --- a/src/main/java/com/owncloud/android/db/ProviderMeta.java +++ b/src/main/java/com/owncloud/android/db/ProviderMeta.java @@ -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 = 47; + public static final int DB_VERSION = 48; private ProviderMeta() { // No instance @@ -190,6 +190,7 @@ public class ProviderMeta { "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"; + public static final String CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME = "richdocument_product_name"; public static final String CAPABILITIES_DEFAULT_SORT_ORDER = CAPABILITIES_ACCOUNT_NAME + " collate nocase asc"; diff --git a/src/main/java/com/owncloud/android/files/FileMenuFilter.java b/src/main/java/com/owncloud/android/files/FileMenuFilter.java index 7895a95154..beb91fe1a8 100644 --- a/src/main/java/com/owncloud/android/files/FileMenuFilter.java +++ b/src/main/java/com/owncloud/android/files/FileMenuFilter.java @@ -106,7 +106,7 @@ public class FileMenuFilter { List toShow = new ArrayList<>(); List toHide = new ArrayList<>(); - filter(toShow, toHide, inSingleFileFragment); + filter(toShow, toHide, inSingleFileFragment, menu); for (int i : toShow) { showMenuItem(menu.findItem(i)); @@ -162,7 +162,7 @@ public class FileMenuFilter { * @param toHide List to save the options that must be shown in the menu. * @param inSingleFileFragment True if this is not listing, but single file fragment, like preview or details. */ - private void filter(List toShow, List toHide, boolean inSingleFileFragment) { + private void filter(List toShow, List toHide, boolean inSingleFileFragment, Menu menu) { boolean synchronizing = anyFileSynchronizing(); OCCapability capability = mComponentsGetter.getStorageManager().getCapability(mAccount.name); boolean endToEndEncryptionEnabled = capability.getEndToEndEncryption().isTrue(); @@ -184,7 +184,7 @@ public class FileMenuFilter { filterUnsetEncrypted(toShow, toHide, endToEndEncryptionEnabled); filterSetPictureAs(toShow, toHide); filterStream(toShow, toHide); - filterOpenAsRichDocument(toShow, toHide, capability); + filterOpenAsRichDocument(toShow, toHide, capability, menu); } private void filterShareFile(List toShow, List toHide, OCCapability capability) { @@ -247,12 +247,25 @@ public class FileMenuFilter { } } - private void filterOpenAsRichDocument(List toShow, List toHide, OCCapability capability) { + private void filterOpenAsRichDocument(List toShow, + List toHide, + OCCapability capability, + Menu menu) { String mimeType = mFiles.iterator().next().getMimeType(); + if (isSingleFile() && android.os.Build.VERSION.SDK_INT >= RichDocumentsWebView.MINIMUM_API && (capability.getRichDocumentsMimeTypeList().contains(mimeType) || capability.getRichDocumentsOptionalMimeTypeList().contains(mimeType)) && capability.getRichDocumentsDirectEditing().isTrue()) { + + String openWith = mContext.getResources().getString(R.string.actionbar_open_as_richdocument_parameter); + String productName = capability.getRichDocumentsProductName(); + MenuItem item = menu.findItem(R.id.action_open_file_as_richdocument); + + if (item != null) { + item.setTitle(String.format(openWith, productName)); + } + toShow.add(R.id.action_open_file_as_richdocument); } else { toHide.add(R.id.action_open_file_as_richdocument); diff --git a/src/main/java/com/owncloud/android/providers/FileContentProvider.java b/src/main/java/com/owncloud/android/providers/FileContentProvider.java index 008b043729..adf0f299eb 100644 --- a/src/main/java/com/owncloud/android/providers/FileContentProvider.java +++ b/src/main/java/com/owncloud/android/providers/FileContentProvider.java @@ -771,7 +771,8 @@ public class FileContentProvider extends ContentProvider { + ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_DIRECT_EDITING + INTEGER + ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_TEMPLATES + INTEGER + ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_OPTIONAL_MIMETYPE_LIST + TEXT - + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ASK_FOR_OPTIONAL_PASSWORD + " INTEGER );"); + + ProviderTableMeta.CAPABILITIES_SHARING_PUBLIC_ASK_FOR_OPTIONAL_PASSWORD + INTEGER + + ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME + " TEXT );"); } private void createUploadsTable(SQLiteDatabase db) { @@ -1966,6 +1967,24 @@ public class FileContentProvider extends ContentProvider { if (!upgraded) { Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion)); } + + if (oldVersion < 48 && newVersion >= 48) { + Log_OC.i(SQL, "Entering in the #48 add product name to capabilities table"); + db.beginTransaction(); + try { + db.execSQL(ALTER_TABLE + ProviderTableMeta.CAPABILITIES_TABLE_NAME + + ADD_COLUMN + ProviderTableMeta.CAPABILITIES_RICHDOCUMENT_PRODUCT_NAME + " TEXT "); + + upgraded = true; + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + } + } + + if (!upgraded) { + Log_OC.i(SQL, String.format(Locale.ENGLISH, UPGRADE_VERSION_MSG, oldVersion, newVersion)); + } } @Override diff --git a/src/main/res/menu/file_actions_menu.xml b/src/main/res/menu/file_actions_menu.xml index 49733694a9..02293b816e 100644 --- a/src/main/res/menu/file_actions_menu.xml +++ b/src/main/res/menu/file_actions_menu.xml @@ -86,7 +86,7 @@ diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 22763fd202..a4d0eaab34 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -794,7 +794,7 @@ Internal streaming not possible Please download media instead or use external app. Folder already exists - Open with Collabora + Open with %1$s Notification icon Create Delete