app/src/google/java/com/geekorum/ttrss/GoogleFlavorApplication.kt
author Da Risk <da_risk@geekorum.com>
Tue, 09 Nov 2021 22:09:00 -0400
changeset 846 ac0863af5ef6
parent 742 47a7b0b61d5e
child 878 fa560bc490f9
permissions -rw-r--r--
build: update licence header check
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
70
156cab5de5b6 Add GoogleFlavorApplicationComponent. Use it to inject GoogleFlavorApplication
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
     1
/*
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     2
 * Geekttrss is a RSS feed reader application on the Android Platform.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     3
 *
846
ac0863af5ef6 build: update licence header check
Da Risk <da_risk@geekorum.com>
parents: 742
diff changeset
     4
 * Copyright (C) 2017-2021 by Frederic-Charles Barthelery.
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     5
 *
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     6
 * This file is part of Geekttrss.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     7
 *
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     8
 * Geekttrss is free software: you can redistribute it and/or modify
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
     9
 * it under the terms of the GNU General Public License as published by
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    10
 * the Free Software Foundation, either version 3 of the License, or
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    11
 * (at your option) any later version.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    12
 *
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    13
 * Geekttrss is distributed in the hope that it will be useful,
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    16
 * GNU General Public License for more details.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    17
 *
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    18
 * You should have received a copy of the GNU General Public License
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    19
 * along with Geekttrss.  If not, see <http://www.gnu.org/licenses/>.
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    20
 */
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    21
package com.geekorum.ttrss
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    22
215
42f01704382b GoogleFlavorApplication: use SplitCompat to give access to downloaded modules
Da Risk <da_risk@geekorum.com>
parents: 197
diff changeset
    23
import android.content.Context
584
8a679747c426 Google: allow disk reads when installing SplitCompat
Da Risk <da_risk@geekorum.com>
parents: 232
diff changeset
    24
import android.os.StrictMode.allowThreadDiskReads
197
304a57b89da3 AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    25
import com.geekorum.geekdroid.dagger.AppInitializer
304a57b89da3 AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    26
import com.geekorum.ttrss.debugtools.StrictModeInitializer
584
8a679747c426 Google: allow disk reads when installing SplitCompat
Da Risk <da_risk@geekorum.com>
parents: 232
diff changeset
    27
import com.geekorum.ttrss.debugtools.withStrictMode
215
42f01704382b GoogleFlavorApplication: use SplitCompat to give access to downloaded modules
Da Risk <da_risk@geekorum.com>
parents: 197
diff changeset
    28
import com.google.android.play.core.splitcompat.SplitCompat
0
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    29
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    30
class GoogleFlavorApplication : Application() {
14443efede32 Initial commit
Da Risk <da_risk@geekorum.com>
parents:
diff changeset
    31
215
42f01704382b GoogleFlavorApplication: use SplitCompat to give access to downloaded modules
Da Risk <da_risk@geekorum.com>
parents: 197
diff changeset
    32
    /**
42f01704382b GoogleFlavorApplication: use SplitCompat to give access to downloaded modules
Da Risk <da_risk@geekorum.com>
parents: 197
diff changeset
    33
     * Allow to load code/resources from on demand modules
42f01704382b GoogleFlavorApplication: use SplitCompat to give access to downloaded modules
Da Risk <da_risk@geekorum.com>
parents: 197
diff changeset
    34
     */
42f01704382b GoogleFlavorApplication: use SplitCompat to give access to downloaded modules
Da Risk <da_risk@geekorum.com>
parents: 197
diff changeset
    35
    override fun attachBaseContext(base: Context?) {
42f01704382b GoogleFlavorApplication: use SplitCompat to give access to downloaded modules
Da Risk <da_risk@geekorum.com>
parents: 197
diff changeset
    36
        super.attachBaseContext(base)
584
8a679747c426 Google: allow disk reads when installing SplitCompat
Da Risk <da_risk@geekorum.com>
parents: 232
diff changeset
    37
        withStrictMode(allowThreadDiskReads()) {
8a679747c426 Google: allow disk reads when installing SplitCompat
Da Risk <da_risk@geekorum.com>
parents: 232
diff changeset
    38
            SplitCompat.install(this)
8a679747c426 Google: allow disk reads when installing SplitCompat
Da Risk <da_risk@geekorum.com>
parents: 232
diff changeset
    39
        }
215
42f01704382b GoogleFlavorApplication: use SplitCompat to give access to downloaded modules
Da Risk <da_risk@geekorum.com>
parents: 197
diff changeset
    40
    }
42f01704382b GoogleFlavorApplication: use SplitCompat to give access to downloaded modules
Da Risk <da_risk@geekorum.com>
parents: 197
diff changeset
    41
197
304a57b89da3 AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    42
    override fun sortAppInitializers(initializers: Set<AppInitializer>): List<AppInitializer> {
304a57b89da3 AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    43
        val result = mutableListOf<AppInitializer>()
304a57b89da3 AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    44
        val strictModeInitializer = initializers.find { it is StrictModeInitializer }
304a57b89da3 AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    45
        strictModeInitializer?.let { result.add(it) }
304a57b89da3 AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    46
        result.addAll(initializers)
304a57b89da3 AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    47
        return result.distinct()
304a57b89da3 AppInitializers: sort them to be sure that some are initialized before others
Da Risk <da_risk@geekorum.com>
parents: 137
diff changeset
    48
    }
70
156cab5de5b6 Add GoogleFlavorApplicationComponent. Use it to inject GoogleFlavorApplication
Da Risk <da_risk@geekorum.com>
parents: 0
diff changeset
    49
}