<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.furry_sos"
    android:versionCode="4001"
    android:versionName="1.0.0" >

    <uses-sdk
        android:minSdkVersion="24"
        android:targetSdkVersion="36" />

    <!-- ========================================== -->
    <!-- 📱 Permission ที่จำเป็น -->
    <!-- ========================================== -->


    <!-- 🌐 อินเทอร์เน็ต (จำเป็นสำหรับ Longdo Map) -->
    <uses-permission android:name="android.permission.INTERNET" />

    <!-- 📍 GPS / ตำแหน่ง -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <!-- 📸 กล้อง -->
    <uses-permission android:name="android.permission.CAMERA" />

    <!-- 🖼️ พื้นที่เก็บข้อมูล (Android 12 และต่ำกว่า) -->
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        android:maxSdkVersion="28" />

    <!-- 🖼️ พื้นที่เก็บข้อมูล (Android 13 ขึ้นไป) -->
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />

    <!-- ========================================== -->
    <!-- 📱 Hardware Features -->
    <!-- ========================================== -->

    <uses-feature
        android:name="android.hardware.camera"
        android:required="false" />
    <uses-feature
        android:name="android.hardware.location.gps"
        android:required="false" />

    <!-- ========================================== -->
    <!-- 🔗 เปิดลิงก์ (url_launcher) -->
    <!-- ========================================== -->

    <queries>

        <!-- 🌐 เว็บไซต์ทั่วไป -->
        <intent>
            <action android:name="android.intent.action.VIEW" />

            <data android:scheme="https" />
        </intent>

        <!-- 📞 โทรออก -->
        <intent>
            <action android:name="android.intent.action.DIAL" />

            <data android:scheme="tel" />
        </intent>

        <!-- 🗺️ เปิดแผนที่ (geo) -->
        <intent>
            <action android:name="android.intent.action.VIEW" />

            <data android:scheme="geo" />
        </intent>

        <!-- 🧭 นำทาง -->
        <intent>
            <action android:name="android.intent.action.VIEW" />

            <data android:scheme="google.navigation" />
        </intent>

        <!-- 📍 เปิดเว็บแผนที่ -->
        <intent>
            <action android:name="android.intent.action.VIEW" />

            <data android:scheme="http" />
        </intent>
    </queries>

    <permission
        android:name="com.example.furry_sos.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.example.furry_sos.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION" />

    <!-- ========================================== -->
    <!-- 📱 Application -->
    <!-- ========================================== -->
    <application
        android:name="android.app.Application"
        android:allowBackup="true"
        android:appComponentFactory="androidx.core.app.CoreComponentFactory"
        android:extractNativeLibs="false"
        android:icon="@mipmap/launcher_icon"
        android:label="Furry SOS"
        android:requestLegacyExternalStorage="true"
        android:theme="@style/LaunchTheme"
        android:usesCleartextTraffic="true" >

        <!-- ========================================== -->
        <!-- 🚀 Main Activity -->
        <!-- ========================================== -->

        <activity
            android:name="com.example.furry_sos.MainActivity"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:exported="true"
            android:hardwareAccelerated="true"
            android:launchMode="singleTop"
            android:taskAffinity=""
            android:theme="@style/LaunchTheme"
            android:windowSoftInputMode="adjustResize" >
            <meta-data
                android:name="io.flutter.embedding.android.NormalTheme"
                android:resource="@style/NormalTheme" />

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- ========================================== -->
        <!-- 🔧 Flutter Embedding -->
        <!-- ========================================== -->

        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />

        <provider
            android:name="io.flutter.plugins.imagepicker.ImagePickerFileProvider"
            android:authorities="com.example.furry_sos.flutter.image_provider"
            android:exported="false"
            android:grantUriPermissions="true" >
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/flutter_image_picker_file_paths" />
        </provider> <!-- Trigger Google Play services to install the backported photo picker module. -->
        <service
            android:name="com.google.android.gms.metadata.ModuleDependencies"
            android:enabled="false"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.google.android.gms.metadata.MODULE_DEPENDENCIES" />
            </intent-filter>

            <meta-data
                android:name="photopicker_activity:0:required"
                android:value="" />
        </service>
        <service
            android:name="com.baseflow.geolocator.GeolocatorLocationService"
            android:enabled="true"
            android:exported="false"
            android:foregroundServiceType="location" />
        <!--
           Declares a provider which allows us to store files to share in
           '.../caches/share_plus' and grant the receiving action access
        -->
        <provider
            android:name="dev.fluttercommunity.plus.share.ShareFileProvider"
            android:authorities="com.example.furry_sos.flutter.share_provider"
            android:exported="false"
            android:grantUriPermissions="true" >
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/flutter_share_file_paths" />
        </provider>
        <!--
           This manifest declared broadcast receiver allows us to use an explicit
           Intent when creating a PendingItent to be informed of the user's choice
        -->
        <receiver
            android:name="dev.fluttercommunity.plus.share.SharePlusPendingIntent"
            android:exported="false" >
            <intent-filter>
                <action android:name="EXTRA_CHOSEN_COMPONENT" />
            </intent-filter>
        </receiver>

        <activity
            android:name="io.flutter.plugins.urllauncher.WebViewActivity"
            android:exported="false"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />

        <uses-library
            android:name="androidx.window.extensions"
            android:required="false" />
        <uses-library
            android:name="androidx.window.sidecar"
            android:required="false" />

        <activity
            android:name="com.google.android.gms.common.api.GoogleApiActivity"
            android:exported="false"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />

        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <provider
            android:name="androidx.startup.InitializationProvider"
            android:authorities="com.example.furry_sos.androidx-startup"
            android:exported="false" >
            <meta-data
                android:name="androidx.lifecycle.ProcessLifecycleInitializer"
                android:value="androidx.startup" />
            <meta-data
                android:name="androidx.profileinstaller.ProfileInstallerInitializer"
                android:value="androidx.startup" />
        </provider>

        <receiver
            android:name="androidx.profileinstaller.ProfileInstallReceiver"
            android:directBootAware="false"
            android:enabled="true"
            android:exported="true"
            android:permission="android.permission.DUMP" >
            <intent-filter>
                <action android:name="androidx.profileinstaller.action.INSTALL_PROFILE" />
            </intent-filter>
            <intent-filter>
                <action android:name="androidx.profileinstaller.action.SKIP_FILE" />
            </intent-filter>
            <intent-filter>
                <action android:name="androidx.profileinstaller.action.SAVE_PROFILE" />
            </intent-filter>
            <intent-filter>
                <action android:name="androidx.profileinstaller.action.BENCHMARK_OPERATION" />
            </intent-filter>
        </receiver>
    </application>

</manifest>