Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/src/main/java/com/nextcloud/utils/EditorUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,10 @@ class EditorUtils @Inject constructor(private val arbitraryDataProvider: Arbitra
}

fun isEditorAvailable(user: User?, mimeType: String?): Boolean = getEditor(user, mimeType) != null

fun usesOfficeUserAgent(editor: Editor?): Boolean = editor?.id in OFFICE_EDITOR_IDS

companion object {
private val OFFICE_EDITOR_IDS = setOf("onlyoffice", "eurooffice")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class TextEditorWebView : EditorWebView() {

val editor = editorUtils.getEditor(user.get(), file?.mimeType)

if (editor != null && editor.id == "onlyoffice") {
webView.settings.userAgentString = generateOnlyOfficeUserAgent()
if (editorUtils.usesOfficeUserAgent(editor)) {
webView.settings.userAgentString = generateOfficeUserAgent()
}

webView.addJavascriptInterface(MobileInterface(), "DirectEditingMobileInterface")
Expand All @@ -72,8 +72,8 @@ class TextEditorWebView : EditorWebView() {
}
}

private fun generateOnlyOfficeUserAgent(): String {
val userAgent = applicationContext.resources.getString(R.string.only_office_user_agent)
private fun generateOfficeUserAgent(): String {
val userAgent = applicationContext.resources.getString(R.string.office_user_agent)

return String.format(userAgent, deviceInfo.androidVersion, appInfo.getAppVersion(this))
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<string name="data_folder">nextcloud</string>
<string name="default_display_name_for_root_folder">Nextcloud</string>
<string name="nextcloud_user_agent">Mozilla/5.0 (Android) Nextcloud-android/%1$s%2$s</string>
<string name="only_office_user_agent">Mozilla/5.0 (Android %1$s) Mobile Nextcloud-android/%2$s</string>
<string name="office_user_agent">Mozilla/5.0 (Android %1$s) Mobile Nextcloud-android/%2$s</string>
<string name="name_for_branded_user_agent"></string>

<!-- URLs and flags related -->
Expand Down
Loading