<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

    <queries>
        <intent>
            <action android:name="android.media.action.IMAGE_CAPTURE" />
        </intent>
    </queries>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@android:style/Theme.Material.NoActionBar"
        android:networkSecurityConfig="@xml/network_security_config">
        <activity
            android:exported="true"
            android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

            <!-- Deep link for password reset -->
            <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="honeydue"
                    android:host="reset-password" />
            </intent-filter>

            <!-- .honeydue file import -->
            <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="content" />
                <data android:scheme="file" />
                <data android:host="*" />
                <data android:mimeType="*/*" />
                <data android:pathPattern=".*\\.honeydue" />
            </intent-filter>

            <!-- .honeydue file import via content:// -->
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />

                <data android:scheme="content" />
                <data android:mimeType="application/octet-stream" />
            </intent-filter>
        </activity>

        <!-- FileProvider for camera photos -->
        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths" />
        </provider>

        <!-- Firebase Cloud Messaging Service (iOS-parity, P4 Stream N).
             Routes incoming data-messages into iOS-equivalent channels
             (task_reminder, task_overdue, residence_invite, subscription). -->
        <service
            android:name=".notifications.FcmService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

        <!-- Default notification channel ID -->
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_channel_id"
            android:value="@string/default_notification_channel_id" />

        <!-- Legacy Notification Action Receiver (widget-era task state actions) -->
        <receiver
            android:name=".NotificationActionReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="com.tt.honeyDue.ACTION_VIEW_TASK" />
                <action android:name="com.tt.honeyDue.ACTION_COMPLETE_TASK" />
                <action android:name="com.tt.honeyDue.ACTION_MARK_IN_PROGRESS" />
                <action android:name="com.tt.honeyDue.ACTION_CANCEL_TASK" />
                <action android:name="com.tt.honeyDue.ACTION_UNCANCEL_TASK" />
            </intent-filter>
        </receiver>

        <!-- iOS-parity push action receiver (P4 Stream O).
             Handles Complete/Snooze/Open for task_reminder & task_overdue, and
             Accept/Decline/Open for residence_invite. Wired to notifications
             built by FcmService.onMessageReceived. Also receives the delayed
             SNOOZE_FIRE alarm from SnoozeScheduler. -->
        <receiver
            android:name=".notifications.NotificationActionReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="com.tt.honeyDue.action.COMPLETE_TASK" />
                <action android:name="com.tt.honeyDue.action.SNOOZE_TASK" />
                <action android:name="com.tt.honeyDue.action.OPEN" />
                <action android:name="com.tt.honeyDue.action.ACCEPT_INVITE" />
                <action android:name="com.tt.honeyDue.action.DECLINE_INVITE" />
                <action android:name="com.tt.honeyDue.action.SNOOZE_FIRE" />
            </intent-filter>
        </receiver>

        <!-- Widget Task Complete Receiver -->
        <receiver
            android:name=".widget.WidgetTaskActionReceiver"
            android:exported="false">
            <intent-filter>
                <action android:name="com.tt.honeyDue.COMPLETE_TASK" />
            </intent-filter>
        </receiver>

        <!-- Small Widget Receiver (2x1) -->
        <receiver
            android:name=".widget.HoneyDueSmallWidgetReceiver"
            android:exported="true"
            android:label="@string/widget_small_name">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/honeydue_small_widget_info" />
        </receiver>

        <!-- Medium Widget Receiver (4x2) -->
        <receiver
            android:name=".widget.HoneyDueMediumWidgetReceiver"
            android:exported="true"
            android:label="@string/widget_medium_name">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/honeydue_medium_widget_info" />
        </receiver>

        <!-- Large Widget Receiver (4x4) -->
        <receiver
            android:name=".widget.HoneyDueLargeWidgetReceiver"
            android:exported="true"
            android:label="@string/widget_large_name">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/honeydue_large_widget_info" />
        </receiver>
    </application>

</manifest>