<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Nextcloud - Android Client
  ~
  ~ SPDX-FileCopyrightText: 2024 TSI-mc <surinder.kumar@t-systems.com>
  ~ SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  ~ SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <uses-permission android:name="android.permission.READ_CALENDAR" />
    <uses-permission android:name="android.permission.WRITE_CALENDAR" /> <!-- Used for document scanning, but lib declares it as required, which it's not -->
    <uses-feature
        android:name="android.hardware.camera2"
        android:required="false"
        tools:node="replace" />
    <!--
 WRITE_EXTERNAL_STORAGE may be enabled or disabled by the user after installation in
        API >= 23; the app needs to handle this
    -->
    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        android:maxSdkVersion="29"
        tools:ignore="ScopedStorage" />
    <uses-permission
        android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
        tools:ignore="ScopedStorage" />
    <uses-permission
        android:name="android.permission.READ_EXTERNAL_STORAGE"
        android:maxSdkVersion="32" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.VIBRATE" /> <!-- Next permissions are always approved in installation time, the apps needs to do nothing special in runtime -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_SYNC_STATS" />
    <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.USE_BIOMETRIC" />
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
    <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
    <uses-permission
        android:name="com.android.launcher.permission.INSTALL_SHORTCUT"
        android:maxSdkVersion="25" />
    <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
    <!--
 Apps that target Android 9 (API level 28) or higher and use foreground services
    must request the FOREGROUND_SERVICE permission
    -->
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <!-- Runtime permissions introduced in Android 13 (API level 33) -->
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
    <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" /> <!-- Needed for Android 14 (API level 34) -->
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
    <!--
 Some Chromebooks don't support touch. Although not essential,
         it's a good idea to explicitly include this declaration.
    -->
    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />

    <queries>
        <package android:name="it.niedermann.nextcloud.deck" />
        <package android:name="it.niedermann.nextcloud.deck.play" />
        <package android:name="it.niedermann.nextcloud.deck.dev" />
        <package android:name="at.bitfire.davdroid" />

        <intent>
            <action android:name="android.intent.action.VIEW" />

            <data android:mimeType="*/*" />
        </intent>
        <intent>
            <action android:name="android.intent.action.SEND" />

            <data android:mimeType="*/*" />
        </intent>
        <intent>
            <action android:name="android.intent.action.SEND_MULTIPLE" />

            <data android:mimeType="*/*" />
        </intent>
        <intent>
            <action android:name="android.intent.action.PICK" />

            <data android:mimeType="*/*" />
        </intent>
        <intent>
            <action android:name="android.media.action.IMAGE_CAPTURE" />
        </intent>
        <intent>
            <action android:name="android.media.action.IMAGE_CAPTURE_SECURE" />
        </intent>
        <intent>
            <action android:name="android.media.action.VIDEO_CAPTURE" />
        </intent>
        <intent>
            <action android:name="android.intent.action.GET_CONTENT" />
        </intent>
    </queries>

    <application
        android:name=".MainApp"
        android:allowBackup="false"
        android:dataExtractionRules="@xml/backup_rules"
        android:fullBackupContent="@xml/backup_config"
        android:icon="@mipmap/ic_launcher"
        android:installLocation="internalOnly"
        android:label="@string/app_name"
        android:manageSpaceActivity="com.owncloud.android.ui.activity.ManageSpaceActivity"
        android:networkSecurityConfig="@xml/network_security_config"
        android:requestLegacyExternalStorage="true"
        android:roundIcon="@mipmap/ic_launcher"
        android:supportsRtl="true"
        android:enableOnBackInvokedCallback="false"
        android:theme="@style/Theme.ownCloud.Toolbar"
        android:usesCleartextTraffic="true"
        tools:ignore="UnusedAttribute"
        tools:replace="android:allowBackup">

        <meta-data android:name="android.content.APP_RESTRICTIONS"
            android:resource="@xml/app_config" />

        <activity
            android:name="com.nextcloud.ui.composeActivity.ComposeActivity"
            android:exported="false" />

        <uses-library
            android:name="org.apache.http.legacy"
            android:required="false" />

        <activity
            android:name=".ui.activity.FileDisplayActivity"
            android:configChanges="orientation|screenSize"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/Theme.ownCloud.Launcher">
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
            </intent-filter>

            <meta-data
                android:name="android.app.searchable"
                android:resource="@xml/users_and_groups_searchable" />

            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="http" />
                <data android:host="*" />
                <data android:pathPattern="/f/..*" />
            </intent-filter>
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="http" />
                <data android:host="*" />
                <data android:pathPattern="/..*/f/..*" />
            </intent-filter>
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="http" />
                <data android:host="*" />
                <data android:pathPattern="/..*/..*/f/..*" />
            </intent-filter>
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="http" />
                <data android:host="*" />
                <data android:pathPattern="/..*/..*/..*/f/..*" />
            </intent-filter>
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="https" />
                <data android:host="*" />
                <data android:pathPattern="/f/..*" />
            </intent-filter>
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="https" />
                <data android:host="*" />
                <data android:pathPattern="/..*/f/..*" />
            </intent-filter>
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="https" />
                <data android:host="*" />
                <data android:pathPattern="/..*/..*/f/..*" />
            </intent-filter>
            <intent-filter android:autoVerify="true">
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="https" />
                <data android:host="*" />
                <data android:pathPattern="/..*/..*/..*/f/..*" />
                <!-- path pattern to handle deep link -->
                <data android:pathPattern="/app/..*" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.activity.ManageAccountsActivity"
            android:exported="false" />
        <activity
            android:name=".ui.activity.UserInfoActivity"
            android:exported="false" />
        <activity
            android:name=".ui.activity.NotificationsActivity"
            android:exported="false" />
        <activity
            android:name=".ui.activity.CommunityActivity"
            android:exported="false" />
        <activity
            android:name=".ui.activities.ActivitiesActivity"
            android:configChanges="orientation|screenSize|keyboardHidden"
            android:exported="false" />
        <activity
            android:name=".ui.activity.SyncedFoldersActivity"
            android:exported="false" />
        <activity
            android:name=".ui.activity.InternalTwoWaySyncActivity"
            android:exported="false" />
        <activity
            android:name="com.nextcloud.client.widget.DashboardWidgetConfigurationActivity"
            android:exported="false">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.canhub.cropper.CropImageActivity"
            android:exported="false"
            tools:replace="android:exported" />

        <receiver
            android:name="com.nextcloud.client.jobs.offlineOperations.receiver.OfflineOperationReceiver"
            android:exported="false" />
        <receiver
            android:name=".operations.upload.UploadFileBroadcastReceiver"
            android:exported="false" />
        <receiver
            android:name="com.nextcloud.client.jobs.MediaFoldersDetectionWork$NotificationReceiver"
            android:exported="false" />
        <receiver
            android:name="com.nextcloud.client.jobs.upload.FileUploadBroadcastReceiver"
            android:exported="false" />
        <receiver
            android:name="com.nextcloud.client.jobs.NotificationWork$NotificationReceiver"
            android:exported="false" />
        <receiver
            android:name="com.nextcloud.client.jobs.upload.FileUploadHelper$UploadNotificationActionReceiver"
            android:exported="false" />
        <receiver
            android:name="com.nextcloud.client.widget.DashboardWidgetProvider"
            android:exported="false">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>

            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/dashboard_widget_info" />
        </receiver>

        <activity
            android:name=".ui.activity.UploadFilesActivity"
            android:configChanges="orientation|screenSize"
            android:exported="false" />
        <activity
            android:name=".ui.activity.ExternalSiteWebView"
            android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
            android:exported="false" />
        <activity
            android:name=".ui.activity.RichDocumentsEditorWebView"
            android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
            android:exported="false" />
        <activity
            android:name=".ui.activity.TextEditorWebView"
            android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
            android:exported="false" />
        <activity
            android:name=".ui.activity.SetupEncryptionActivity"
            android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
            android:exported="false"
            android:theme="@style/Theme.NoBackground" />
        <activity
            android:name=".ui.activity.ContactsPreferenceActivity"
            android:exported="false"
            android:launchMode="singleInstance" />
        <activity
            android:name=".ui.activity.ChooseStorageLocationActivity"
            android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
            android:exported="false"
            android:theme="@style/Theme.NoBackground" />
        <activity
            android:name=".ui.activity.ReceiveExternalFilesActivity"
            android:excludeFromRecents="true"
            android:exported="true"
            android:taskAffinity=""
            android:theme="@style/Theme.ownCloud.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.SEND" />

                <category android:name="android.intent.category.DEFAULT" />

                <data android:mimeType="*/*" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND_MULTIPLE" />

                <category android:name="android.intent.category.DEFAULT" />

                <data android:mimeType="*/*" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.activity.SettingsActivity"
            android:exported="false"
            android:theme="@style/PreferenceTheme" />
        <activity
            android:name=".ui.preview.PreviewImageActivity"
            android:exported="false"
            android:theme="@style/Theme.ownCloud.Overlay" />
        <activity
            android:name=".ui.preview.PreviewMediaActivity"
            android:configChanges="orientation|screenLayout|screenSize|keyboardHidden"
            android:exported="false"
            android:theme="@style/Theme.ownCloud.Media" />

        <service
            android:name="com.nextcloud.client.media.BackgroundPlayerService"
            android:foregroundServiceType="mediaPlayback"
            android:exported="true"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="androidx.media3.session.MediaSessionService"/>
            </intent-filter>
        </service>

        <service
            android:name=".authentication.AccountAuthenticatorService"
            android:exported="false">
            <intent-filter android:priority="100">
                <action android:name="android.accounts.AccountAuthenticator" />
            </intent-filter>

            <meta-data
                android:name="android.accounts.AccountAuthenticator"
                android:resource="@xml/authenticator" />
        </service>
        <service
            android:name=".syncadapter.FileSyncService"
            android:exported="true"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.content.SyncAdapter" />
            </intent-filter>

            <meta-data
                android:name="android.content.SyncAdapter"
                android:resource="@xml/syncadapter_files" />
        </service>
        <service
            android:name="com.nextcloud.client.widget.DashboardWidgetService"
            android:exported="true"
            android:permission="android.permission.BIND_REMOTEVIEWS" />

        <provider
            android:name=".providers.FileContentProvider"
            android:authorities="@string/authority"
            android:enabled="true"
            android:exported="true"
            android:label="@string/sync_string_files"
            android:syncable="true">
            <path-permission
                android:pathPrefix="/shares"
                android:readPermission="false"
                android:writePermission="false" />
            <path-permission
                android:pathPrefix="/capabilities"
                android:readPermission="false"
                android:writePermission="false" />
            <path-permission
                android:pathPrefix="/uploads"
                android:readPermission="false"
                android:writePermission="false" />
            <path-permission
                android:pathPrefix="/synced_folders"
                android:readPermission="false"
                android:writePermission="false" />
            <path-permission
                android:pathPrefix="/external_links"
                android:readPermission="false"
                android:writePermission="false" />
            <path-permission
                android:pathPrefix="/virtual"
                android:readPermission="false"
                android:writePermission="false" />
            <path-permission
                android:pathPrefix="/filesystem"
                android:readPermission="false"
                android:writePermission="false" />
        </provider>
        <provider
            android:name=".providers.UsersAndGroupsSearchProvider"
            android:authorities="@string/users_and_groups_search_authority"
            android:enabled="true"
            android:exported="false"
            android:label="@string/share_search" />
        <provider
            android:name=".providers.DocumentsStorageProvider"
            android:authorities="@string/document_provider_authority"
            android:enabled="true"
            android:exported="true"
            android:grantUriPermissions="true"
            android:permission="android.permission.MANAGE_DOCUMENTS">
            <intent-filter>
                <action android:name="android.content.action.DOCUMENTS_PROVIDER" />
            </intent-filter>
        </provider> <!-- new provider used to generate URIs without file:// scheme (forbidden from Android 7) -->
        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="@string/file_provider_authority"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/exposed_filepaths" />
        </provider>
        <provider
            android:name=".providers.DiskLruImageCacheFileProvider"
            android:authorities="@string/image_cache_provider_authority"
            android:exported="true"
            android:grantUriPermissions="true"
            android:permission="android.permission.MANAGE_DOCUMENTS" /> <!-- Disable WorkManager initialization. Whoever designed this, should pay closer attention -->
        <!-- to "best before" dates in his fridge. -->
        <!-- disable default provider -->
        <provider
            android:name="androidx.startup.InitializationProvider"
            android:authorities="${applicationId}.androidx-startup"
            android:exported="false"
            tools:node="merge">
            <meta-data
                android:name="androidx.work.WorkManagerInitializer"
                android:value="androidx.startup"
                tools:node="remove" />
        </provider>

        <activity
            android:name=".authentication.AuthenticatorActivity"
            android:configChanges="orientation|screenSize|keyboard|keyboardHidden"
            android:exported="true"
            android:launchMode="singleTask"
            android:theme="@style/Theme.ownCloud.noActionBar.Login">
            <intent-filter>
                <action android:name="com.owncloud.android.workaround.accounts.CREATE" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity
            android:name=".authentication.DeepLinkLoginActivity"
            android:clearTaskOnLaunch="true"
            android:configChanges="orientation|screenSize|keyboardHidden"
            android:exported="true"
            android:launchMode="singleTask"
            android:theme="@style/Theme.ownCloud.noActionBar.Login">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:host="login"
                    android:scheme="@string/login_data_own_scheme" />
            </intent-filter>
        </activity>

        <service
            android:name="androidx.work.impl.foreground.SystemForegroundService"
            android:directBootAware="false"
            android:enabled="@bool/enable_system_foreground_service_default"
            android:exported="false"
            android:foregroundServiceType="dataSync" />
        <service
            android:name=".services.OperationsService"
            android:exported="false" />
        <service
            android:name="com.nextcloud.client.jobs.transfer.FileTransferService"
            android:exported="false"
            android:foregroundServiceType="dataSync" />
        <service
            android:name="com.nextcloud.client.media.PlayerService"
            android:exported="false"
            android:foregroundServiceType="mediaPlayback" />

        <activity
            android:name=".ui.activity.PassCodeActivity"
            android:exported="false"
            android:launchMode="singleTask" />
        <activity
            android:name=".ui.activity.RequestCredentialsActivity"
            android:exported="false"
            android:launchMode="singleTask" />
        <activity
            android:name=".ui.activity.ConflictsResolveActivity"
            android:exported="false" />
        <activity
            android:name=".ui.activity.ErrorsWhileCopyingHandlerActivity"
            android:exported="false" />
        <activity
            android:name="com.nextcloud.client.logger.ui.LogsActivity"
            android:exported="false" />
        <activity
            android:name="com.nextcloud.client.errorhandling.ShowErrorActivity"
            android:excludeFromRecents="true"
            android:exported="false"
            android:finishOnTaskLaunch="true"
            android:launchMode="singleInstance"
            android:process=":crash"
            android:theme="@style/Theme.ownCloud.Toolbar" />
        <activity
            android:name=".ui.activity.UploadListActivity"
            android:exported="false" />
        <activity
            android:name=".ui.trashbin.TrashbinActivity"
            android:configChanges="orientation|screenSize|keyboardHidden"
            android:exported="true" />
        <activity
            android:name="com.nextcloud.client.onboarding.WhatsNewActivity"
            android:theme="@style/Theme.ownCloud.noActionBar.Login" />
        <activity
            android:name="com.nextcloud.client.onboarding.FirstRunActivity"
            android:configChanges="orientation|screenSize"
            android:exported="false"
            android:theme="@style/Theme.ownCloud.noActionBar.Login" />

        <receiver
            android:name=".files.BootupBroadcastReceiver"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
                <action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
            </intent-filter>
        </receiver>

        <activity
            android:name=".ui.activity.CopyToClipboardActivity"
            android:exported="false"
            android:icon="@drawable/shared_via_link"
            android:label="@string/copy_link" />
        <activity
            android:name=".ui.activity.FolderPickerActivity"
            android:exported="false" />
        <activity
            android:name=".ui.activity.FilePickerActivity"
            android:exported="false"
            android:launchMode="singleTop"
            android:theme="@style/Theme.ownCloud.Dialog.NoTitle"
            android:windowSoftInputMode="adjustResize" />
        <activity
            android:name=".ui.activity.ShareActivity"
            android:exported="false"
            android:label="@string/share_dialog_title"
            android:launchMode="singleTop"
            android:theme="@style/Theme.ownCloud.Dialog.NoTitle"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
            </intent-filter>

            <meta-data
                android:name="android.app.searchable"
                android:resource="@xml/users_and_groups_searchable" />
        </activity>
        <activity
            android:name=".ui.activity.ManageSpaceActivity"
            android:exported="false"
            android:label="@string/manage_space_title" />

        <service
            android:name=".services.AccountManagerService"
            android:enabled="true"
            android:exported="true"
            tools:ignore="ExportedService" />

        <activity
            android:name=".ui.activity.SsoGrantPermissionActivity"
            android:exported="true"
            android:theme="@style/Theme.ownCloud.Dialog.NoTitle" />
        <activity
            android:name="com.nextcloud.client.etm.EtmActivity"
            android:exported="false"
            android:theme="@style/Theme.ownCloud.Toolbar" />
        <activity
            android:name=".ui.preview.PreviewBitmapActivity"
            android:exported="false"
            android:theme="@style/Theme.ownCloud.OverlayGrey" />
        <activity
            android:name="com.nextcloud.client.documentscan.DocumentScanActivity"
            android:exported="false"
            android:theme="@style/Theme.ownCloud.Toolbar" />
        <activity
            android:name="com.nextcloud.client.editimage.EditImageActivity"
            android:exported="false"
            android:theme="@style/Theme.ownCloud.Toolbar.NullBackground" />
        <activity
            android:name="com.nmc.android.ui.LauncherActivity"
            android:exported="true"
            android:theme="@style/Theme.App.Starting">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
