Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Android 14 #347

Merged
30 commits merged into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a8d66d7
Bump to SDK 34
Jean-BaptisteC Sep 16, 2023
823d9d7
Add rule to used official style code
Jean-BaptisteC Sep 16, 2023
b1cb4a6
Bump dependencies
Jean-BaptisteC Sep 16, 2023
655f29e
Finish migration to material textview
Jean-BaptisteC Sep 16, 2023
4daa123
Disable Jetifier
Jean-BaptisteC Sep 17, 2023
2a68cb0
Fix translations
Jean-BaptisteC Sep 17, 2023
d0a41a2
Remove deprecation
Jean-BaptisteC Sep 17, 2023
a944243
Fix errors
Jean-BaptisteC Sep 19, 2023
c51c257
Fix typo
Jean-BaptisteC Sep 19, 2023
7cdbdd7
Remove variable in date function
Jean-BaptisteC Sep 19, 2023
e6f001a
Fix style of icons
Jean-BaptisteC Sep 19, 2023
03ea728
Fix format and ending files
Jean-BaptisteC Sep 20, 2023
053babf
Migrate to kotlin test
Jean-BaptisteC Sep 23, 2023
e37fe6e
Enable predictive back gesture
Jean-BaptisteC Oct 5, 2023
f0375c9
Bump dependencies
Jean-BaptisteC Oct 5, 2023
016290a
Bump to gradle 8.3
Jean-BaptisteC Oct 5, 2023
7aa3d9e
Fix deprecation
Jean-BaptisteC Oct 5, 2023
cf99809
Remove useless task
Jean-BaptisteC Oct 7, 2023
ea80682
Bump dependencies
Jean-BaptisteC Oct 7, 2023
d5798ac
Fix import
Jean-BaptisteC Oct 7, 2023
2b77a16
Migrate to material component
Jean-BaptisteC Oct 7, 2023
070ebfb
Fix format
Jean-BaptisteC Oct 7, 2023
4beb854
Update Mastodon link
Jean-BaptisteC Oct 15, 2023
11f8b9e
Add new button to change app language
Jean-BaptisteC Oct 15, 2023
fd89742
Remove build type on AboutFragment
Jean-BaptisteC Oct 15, 2023
1ace871
Reorganize Turkish translations
Jean-BaptisteC Oct 15, 2023
0f1581c
Bump to Gradle 8.4
Jean-BaptisteC Oct 18, 2023
117104c
Update dependencies
Jean-BaptisteC Oct 24, 2023
b891b8e
Improve build.gradle
Jean-BaptisteC Oct 28, 2023
bb7dd2c
Update dependencies
Jean-BaptisteC Nov 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ plugins {

android {
namespace = "org.eu.exodus_privacy.exodusprivacy"
compileSdk = 33
compileSdk = 34

defaultConfig {
applicationId = "org.eu.exodus_privacy.exodusprivacy"
minSdk = 21
targetSdk = 33
targetSdk = 34
versionCode = 16
versionName = "3.1.1"
testInstrumentationRunner = "org.eu.exodus_privacy.exodusprivacy.ExodusTestRunner"
Expand Down Expand Up @@ -47,12 +47,12 @@ android {
}

buildTypes {
getByName("debug") {
debug {
applicationIdSuffix = ".debug"
versionNameSuffix = "-debug"
isDebuggable = true
}
getByName("release") {
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
Expand All @@ -71,6 +71,9 @@ android {
isIncludeAndroidResources = true
}
}
packagingOptions {
resources.excludes.add("META-INF/*")
}
sourceSets {
// Adds exported schema location as test app assets.
getByName("androidTest").assets.srcDirs("$projectDir/schemas")
Expand Down Expand Up @@ -162,6 +165,7 @@ dependencies {
androidTestImplementation(libs.kotlinx.coroutines.test)
androidTestImplementation(libs.okhttp.mockwebserver)
androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(kotlin("test"))
}

class RoomSchemaArgProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import org.eu.exodus_privacy.exodusprivacy.manager.database.ExodusDatabase
import org.junit.Rule
import org.junit.Test
import java.io.IOException
import kotlin.test.Test

class FakeAutoMigrationSpec : AutoMigrationSpec {
@Override
Expand All @@ -34,7 +34,7 @@ class DatabaseMigrationTest {
FrameworkSQLiteOpenHelperFactory()
)

val MIGRATION_1_2 = object : Migration(1, 2) {
private val MIGRATION_1_2 = object : Migration(1, 2) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(
"ALTER TABLE TrackerData ADD COLUMN totalNumberOfAppsHavingTrackers INTEGER NOT NULL DEFAULT 0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ import okhttp3.mockwebserver.SocketPolicy
import org.eu.exodus_privacy.exodusprivacy.manager.network.ExodusAPIInterface
import org.eu.exodus_privacy.exodusprivacy.manager.network.ExodusAPIRepository
import org.eu.exodus_privacy.exodusprivacy.manager.network.ExodusModule
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.Test
import kotlin.time.Duration.Companion.seconds

const val FAKE_PATH = "/api/requests/"
Expand Down Expand Up @@ -100,14 +100,14 @@ class ExodusAPIRepositoryTest {
lateinit var exodusAPIRepository: ExodusAPIRepository
private lateinit var context: Context

@Before
@BeforeTest
fun setup() {
context = InstrumentationRegistry.getInstrumentation().context
mockWebServer.start(FAKE_PORT)
mockWebServer.url(FAKE_PATH)
}

@After
@AfterTest
fun teardown() {
mockWebServer.shutdown()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import kotlinx.coroutines.test.runTest
import org.eu.exodus_privacy.exodusprivacy.manager.storage.DataStoreName
import org.eu.exodus_privacy.exodusprivacy.manager.storage.ExodusConfig
import org.eu.exodus_privacy.exodusprivacy.manager.storage.ExodusDataStoreRepository
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import kotlin.test.BeforeTest
import kotlin.test.Test

@HiltAndroidTest
class ExodusDataStoreRepositoryTest {
Expand All @@ -24,7 +24,7 @@ class ExodusDataStoreRepositoryTest {
private lateinit var context: Context
private lateinit var dataStoreRepository: ExodusDataStoreRepository<ExodusConfig>

@Before
@BeforeTest
fun setup() {
context = getInstrumentation().targetContext
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import org.eu.exodus_privacy.exodusprivacy.manager.database.app.ExodusApplicatio
import org.eu.exodus_privacy.exodusprivacy.manager.database.tracker.TrackerData
import org.eu.exodus_privacy.exodusprivacy.objects.Permission
import org.eu.exodus_privacy.exodusprivacy.objects.Source
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import java.io.InputStream
import kotlin.test.AfterTest
import kotlin.test.BeforeTest
import kotlin.test.Test

@HiltAndroidTest
class ExodusDatabaseRepositoryTest {
Expand Down Expand Up @@ -60,7 +60,7 @@ class ExodusDatabaseRepositoryTest {

private val resolution = 144

@Before
@BeforeTest
fun setup() {
context = InstrumentationRegistry.getInstrumentation().context
assets = context.assets
Expand Down Expand Up @@ -134,7 +134,7 @@ class ExodusDatabaseRepositoryTest {
)
}

@After
@AfterTest
fun teardown() {
testDB.clearAllTables()
testDB.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import kotlinx.coroutines.test.runTest
import org.eu.exodus_privacy.exodusprivacy.manager.packageinfo.ExodusPackageRepository
import org.eu.exodus_privacy.exodusprivacy.utils.getInstalledPackagesList
import org.junit.Rule
import org.junit.Test
import javax.inject.Inject
import kotlin.test.Test

@HiltAndroidTest
class ExodusPackageRepositoryTest {
Expand Down Expand Up @@ -119,7 +119,6 @@ class ExodusPackageRepositoryTest {
pkg.applicationInfo.name
val appInfo = pkg.applicationInfo
comparePkgInfo = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
@Suppress("DEPRECATION")
packageManager.getApplicationInfo(
pkg.packageName,
0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ExodusTestRunner : AndroidJUnitRunner() {
): Application {
return super.newApplication(
cl,
HiltTestApplication::class.java.getName(),
HiltTestApplication::class.java.name,
context
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import androidx.test.rule.ServiceTestRule
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import org.eu.exodus_privacy.exodusprivacy.manager.database.app.ExodusApplication
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import kotlin.test.BeforeTest
import kotlin.test.Test

@HiltAndroidTest
class ExodusUpdateServiceTest {
Expand All @@ -24,7 +24,7 @@ class ExodusUpdateServiceTest {

private lateinit var context: Context

@Before
@BeforeTest
fun setup() {
context = InstrumentationRegistry.getInstrumentation().targetContext
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@

<!-- Testing:
To test timeouts of the ExodusAPIRepository in instrumentation, add the following line
to the application tag tag:
to the application tag:
android:networkSecurityConfig="@xml/network_security_config"
-->

<application
android:name=".ExodusApplication"
android:allowBackup="false"
android:dataExtractionRules="@xml/data_extraction_rules"
android:enableOnBackInvokedCallback="true"
android:fullBackupContent="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ExodusUpdateService : LifecycleService() {
private var notificationPermGranted = false

// Inject required modules
var applicationList = mutableListOf<Application>()
private var applicationList = mutableListOf<Application>()
private var applicationListAfterUninstall = mutableListOf<Application>()

@Inject
Expand Down Expand Up @@ -264,7 +264,12 @@ class ExodusUpdateService : LifecycleService() {
exodusDatabaseRepository.saveApp(it)
}
Log.d(TAG, "Done saving app details.")
exodusDataStoreRepository.insertAppSetup(ExodusConfig("is_setup_complete", true))
exodusDataStoreRepository.insertAppSetup(
ExodusConfig(
"is_setup_complete",
true
)
)
// We are done, gracefully exit!
stopService()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package org.eu.exodus_privacy.exodusprivacy.fragments.about
import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import android.view.View
import android.widget.Toast
import androidx.browser.customtabs.CustomTabsIntent
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
Expand Down Expand Up @@ -33,7 +36,7 @@ class AboutFragment : PreferenceFragmentCompat() {
private const val sourceCodeURL = "https://github.com/Exodus-Privacy/exodus-android-app"
private const val websiteURL = "https://exodus-privacy.eu.org/"
private const val twitterURL = "https://twitter.com/ExodusPrivacy"
private const val mastodonURL = "https://framapiaf.org/@exodus"
private const val mastodonURL = "https://mastodon.social/@exodus@framapiaf.org"
private const val emailID = "[email protected]"
}

Expand All @@ -56,23 +59,39 @@ class AboutFragment : PreferenceFragmentCompat() {
val toolbar = binding.toolbar
toolbar.menu.clear()
toolbar.inflateMenu(R.menu.about_menu)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
(toolbar.menu.findItem(R.id.chooseLanguage)).isVisible = true
}
toolbar.setOnMenuItemClickListener {
when (it.itemId) {
R.id.chooseLanguage -> {
val intent = Intent(Settings.ACTION_APP_LOCALE_SETTINGS).apply {
data = Uri.parse("package:" + BuildConfig.APPLICATION_ID)
}
try {
startActivity(intent)
true
} catch (e: ActivityNotFoundException) {
false
}
}

R.id.chooseTheme -> {
ThemeDialogFragment().show(childFragmentManager, tag)
}
}
true
}

val type = BuildConfig.BUILD_TYPE.replaceFirstChar { it.uppercase() }
binding.appVersionTV.text =
getString(
R.string.version_info,
type,
BuildConfig.VERSION_NAME,
BuildConfig.VERSION_CODE
)
binding.appVersionTV.setOnClickListener {
Toast.makeText(context, "Thanks for support ❤", Toast.LENGTH_SHORT).show()
}
}

override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class AppDetailViewModel @Inject constructor(
}

fun getFormattedReportDate(date: String, context: Context): String {
// Generate date object in currentSDF to format
val currentSDF = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
val currentDate = currentSDF.parse(date.split("T")[0])
// Generate date object in currentSDF to format and parse
val currentDate =
SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(date.split("T")[0])
// Format it
val sdf = DateFormat.getLongDateFormat(context)
return sdf.format(currentDate!!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ class TrackersRVAdapter(

Log.d(
TAG,
"ApplicationsList in TrackerData: ${app.exodusApplications}. " +
"Size: ${app.exodusApplications.size}."
"ApplicationsList in TrackerData: ${app.exodusApplications}. " + "Size: ${app.exodusApplications.size}."
)

val trackerPercentage =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ class ExodusDatabaseRepository @Inject constructor(
return@withContext if (list.isNotEmpty() && list.size == 1) {
list[0]
} else {
Log.d(TAG, "Failed to get ExodusApplication from DB returning empty ExodusApplication().")
Log.d(
TAG,
"Failed to get ExodusApplication from DB returning empty ExodusApplication()."
)
ExodusApplication()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ class ExodusAPIRepository @Inject constructor(
Log.d(TAG, "Success!")
result.body()!!
} else {
Log.w(TAG, "Failed to get trackers, response code: ${result.code()}. Returning empty Trackers object.")
Log.w(
TAG,
"Failed to get trackers, response code: ${result.code()}. Returning empty Trackers object."
)
Trackers()
}
} else {
Expand All @@ -43,7 +46,10 @@ class ExodusAPIRepository @Inject constructor(
Log.d(TAG, "Success!")
result.body()!!
} else {
Log.w(TAG, "Failed to get app details, response code: ${result.code()}. Returning emptyList.")
Log.w(
TAG,
"Failed to get app details, response code: ${result.code()}. Returning emptyList."
)
emptyList()
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ExodusDataStoreRepository<ExodusConfig> @Inject constructor(
private val gson: Gson,
private val preferenceKey: Preferences.Key<String>,
private val typeToken: TypeToken<Map<String, ExodusConfig>>,
private val name: DataStoreName,
name: DataStoreName,
@ApplicationContext val context: Context
) : ExodusStorage<ExodusConfig> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ fun Chip.setExodusColor(size: Int) {
this.chipBackgroundColor = backgroundColorStateList
} else {
val colorForeground =
ColorStateList.valueOf(ContextCompat.getColor(context, com.google.android.material.R.color.m3_chip_text_color))
ColorStateList.valueOf(
ContextCompat.getColor(
context,
com.google.android.material.R.color.m3_chip_text_color
)
)
this.chipIconTint = colorForeground
this.setTextColor(colorForeground)
val colorBackground = ContextCompat.getColor(context, R.color.chipColor)
Expand Down Expand Up @@ -69,7 +74,6 @@ fun getLanguage(): String {

fun PackageManager.getInstalledPackagesList(flags: Int): List<PackageInfo> {
return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
@Suppress("DEPRECATION")
this.getInstalledPackages(flags)
} else {
val newFlags = PackageManager.PackageInfoFlags.of(flags.toLong())
Expand Down
Loading