<manifest xmlns:android="http://schemas.android.com/apk/res/android"
	android:installLocation="auto">

	<uses-permission android:name="android.permission.INTERNET" />
	<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
	<uses-permission android:name="android.permission.CAMERA" />
	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
	<uses-permission android:name="android.permission.USE_BIOMETRIC" />
	<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
	<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
	<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
	<uses-permission android:name="android.permission.RECORD_AUDIO" />

	<!-- Make these features optional to enable Chromebooks -->
	<!-- https://github.com/laurent22/joplin/issues/37 -->
	<uses-feature android:name="android.hardware.camera" android:required="false" />
	<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />

	<!-- Need this block to support viewing files in with Android API 30 -->
	<!-- https://github.com/vinzscam/react-native-file-viewer/issues/94#issuecomment-767743365 -->
	<queries>
		<intent>
			<action android:name="android.intent.action.VIEW" />
			<data android:mimeType="*/*" />
		</intent>
	</queries>

	<!--
		android:requestLegacyExternalStorage: Android 10 introduced new "scoped storage" mechanism.
		Apps targeting Android 10 (sdk 29) can no longer freely access arbitrary paths on the shared storage.
		This attribute allows to opt out of this restriction.

		android:resizeableActivity: allows user to resize Joplin window
		https://github.com/laurent22/joplin/issues/3547

		android:enableOnBackInvokedCallback: Workaround: Joplin currently does not support predictive back gestures.
		- https://stackoverflow.com/a/79861863
		- https://github.com/laurent22/joplin/issues/14265
		- https://developer.android.com/guide/navigation/custom-back/predictive-back-gesture
	-->
	<application
		android:name=".MainApplication"
		android:label="@string/app_name"
		android:icon="@mipmap/ic_launcher"
		android:roundIcon="@mipmap/ic_launcher_round"
		android:allowBackup="false"
		android:networkSecurityConfig="@xml/network_security_config"
		android:requestLegacyExternalStorage="true"
		android:resizeableActivity="true"
		android:theme="@style/AppTheme"
		android:enableOnBackInvokedCallback="false"
		android:usesCleartextTraffic="${usesCleartextTraffic}"
		android:supportsRtl="true">

		<!-- Enable profiling in release builds (Android 10+) -->
		<profileable android:shell="true" />

		<!--
		2018-12-16: Changed android:launchMode from "singleInstance" to "singleTop" for Firebase notification
					Previously singleInstance was necessary to prevent multiple instance of the RN app from running at the same time, but maybe no longer needed.

		2020-10-06: Changed back again to "singleInstance" and notifications still seem to work. Changing to singleInstance
					to try to fix this bug: https://discourse.joplinapp.org/t/joplin-android-app-looses-nextcloud-sync-settings/10997/6
					Users would lose their settings, and it's possibly due to multiple instances of the app running at the same time, perhaps
					due to sharing with the app. When checking the log, it would show "saving settings", then the app startup message, and after the app
					has started, it would show "setting saved". So basically the app, or one instance of it, has started while settings were being saved

		2020-10-08: Changed back again to "singleTop" as it has worked so far. The multiple instance bug was "fixed" in a different way
					See packages/app-mobile/root.js for more info about the bug.

		2021-11-20: Changed to "singleTask" to ensure deep linking doesn't cause multiple instances.
					This is recommended in the React docs: https://reactnavigation.org/docs/deep-linking. In practice, "singleTask" and "singleTop" are
					largely similar, but "singleTask" is more strict in preventing multiple instances of the app from being created if another app
					explicitly requests it.

		2022-08-12: Added `screenLayout` and `smallestScreenSize` to `android:configChanges`.
					This prevents the application from being re-constructed on
					screen orientation change/window resizes on some devices.
					See https://github.com/laurent22/joplin/pull/6737.
		-->

		<activity
			android:name=".MainActivity"
			android:label="@string/app_name"
			android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
			android:launchMode="singleTask"
			android:windowSoftInputMode="adjustResize"
			android:exported="true">
			<intent-filter>
				<action android:name="android.intent.action.MAIN" />
				<category android:name="android.intent.category.LAUNCHER" />
			</intent-filter>

			<!-- SHARE EXTENSION -->
			<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>
			<!-- /SHARE EXTENSION -->

			<!-- EXTERNAL LINK -->
			<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:scheme="joplin" />
			</intent-filter>
			<!-- /EXTERNAL LINK -->
		</activity>

	</application>

</manifest>
