<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="io.github.wulkanowy"
    android:installLocation="internalOnly">

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>

    <queries>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="http" />
        </intent>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="https" />
        </intent>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="mailto" />
        </intent>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="tel" />
        </intent>
        <intent>
            <action android:name="android.intent.action.VIEW" />
            <data android:scheme="geo" />
        </intent>
    </queries>

    <application
        android:name=".WulkanowyApp"
        android:allowBackup="false"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:networkSecurityConfig="@xml/network_security_config"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="false"
        android:theme="@style/WulkanowyTheme"
        tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">
        <activity
            android:name=".ui.modules.splash.SplashActivity"
            android:exported="true"
            android:screenOrientation="portrait"
            android:theme="@style/WulkanowyTheme.SplashScreen"
            tools:ignore="LockedOrientationActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.modules.login.LoginActivity"
            android:configChanges="orientation|screenSize"
            android:label="@string/login_title"
            android:theme="@style/WulkanowyTheme.Login"
            android:windowSoftInputMode="adjustResize" />
        <activity
            android:name=".ui.modules.main.MainActivity"
            android:configChanges="orientation|screenSize"
            android:label="@string/main_title"
            android:theme="@style/WulkanowyTheme.NoActionBar"
            android:windowSoftInputMode="adjustPan" />
        <activity
            android:name=".ui.modules.message.send.SendMessageActivity"
            android:configChanges="orientation|screenSize"
            android:label="@string/send_message_title"
            android:theme="@style/WulkanowyTheme.MessageSend"
            android:windowSoftInputMode="adjustResize" />
        <activity
            android:name=".ui.modules.timetablewidget.TimetableWidgetConfigureActivity"
            android:excludeFromRecents="true"
            android:exported="true"
            android:noHistory="true"
            android:theme="@style/WulkanowyTheme.WidgetAccountSwitcher">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ui.modules.luckynumberwidget.LuckyNumberWidgetConfigureActivity"
            android:excludeFromRecents="true"
            android:exported="true"
            android:noHistory="true"
            android:theme="@style/WulkanowyTheme.WidgetAccountSwitcher">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
            </intent-filter>
        </activity>

        <service
            android:name=".services.widgets.TimetableWidgetService"
            android:permission="android.permission.BIND_REMOTEVIEWS" />
        <service
            android:name=".services.piggyback.VulcanNotificationListenerService"
            android:exported="true"
            android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
            <intent-filter>
                <action android:name="android.service.notification.NotificationListenerService" />
            </intent-filter>
        </service>
        <service
            android:name=".services.messaging.AppMessagingService"
            android:exported="false"
            tools:ignore="MissingClass">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>

        <receiver
            android:name=".ui.modules.timetablewidget.TimetableWidgetProvider"
            android:exported="true"
            android:label="@string/timetable_title">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/provider_widget_timetable" />
        </receiver>
        <receiver
            android:name=".ui.modules.luckynumberwidget.LuckyNumberWidgetProvider"
            android:exported="true"
            android:label="@string/lucky_number_title">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/provider_widget_lucky_number" />
        </receiver>

        <receiver android:name=".services.alarm.TimetableNotificationReceiver" />

        <provider
            android:name="androidx.startup.InitializationProvider"
            android:authorities="${applicationId}.androidx-startup"
            tools:node="remove" />
        <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/provider_paths" />
        </provider>

        <!-- workaround for https://github.com/firebase/firebase-android-sdk/issues/473 enabled:false -->
        <!-- https://firebase.googleblog.com/2017/03/take-control-of-your-firebase-init-on.html -->
        <provider
            android:name="com.google.firebase.provider.FirebaseInitProvider"
            android:authorities="${applicationId}.firebaseinitprovider"
            android:enabled="${firebase_enabled}"
            android:exported="false"
            tools:ignore="MissingClass" />

        <meta-data
            android:name="install_channel"
            android:value="${install_channel}" />
        <meta-data
            android:name="firebase_analytics_collection_enabled"
            android:value="${firebase_enabled}" />
        <meta-data
            android:name="google_analytics_adid_collection_enabled"
            android:value="${firebase_enabled}" />
        <meta-data
            android:name="firebase_crashlytics_collection_enabled"
            android:value="${firebase_enabled}" />
        <meta-data
            android:name="firebase_messaging_auto_init_enabled"
            android:value="${firebase_enabled}" />
        <meta-data
            android:name="firebase_inapp_messaging_auto_data_collection_enabled"
            android:value="${firebase_enabled}" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_icon"
            android:resource="@drawable/ic_stat_all" />
        <meta-data
            android:name="com.google.firebase.messaging.default_notification_channel_id"
            android:value="push_channel" />
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="${admob_project_id}" />
        <meta-data
            android:name="com.google.android.gms.ads.DELAY_APP_MEASUREMENT_INIT"
            android:value="true" />
    </application>
</manifest>
