Loading app/build.gradle +1 −2 Original line number Diff line number Diff line Loading @@ -135,8 +135,7 @@ dependencies { // Optional -- mockito-kotlin testImplementation "org.mockito.kotlin:mockito-kotlin:3.2.0" testImplementation 'org.mockito:mockito-inline:2.13.0' testImplementation "androidx.arch.core:core-testing:2.1.0" // Coil and PhotoView implementation "io.coil-kt:coil:1.4.0" Loading app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt +9 −11 Original line number Diff line number Diff line Loading @@ -365,11 +365,11 @@ class FusedAPIImpl @Inject constructor( val status = runCodeBlockWithTimeout({ if (preferenceManagerModule.isGplaySelected()) { getGplayPackagResult(query, authData, gplayPackageResult) gplayPackageResult = getGplayPackagResult(query, authData) } if (preferenceManagerModule.isOpenSourceSelected()) { getCleanApkPackageResult(query, cleanapkPackageResult) cleanapkPackageResult = getCleanApkPackageResult(query) } }) Loading @@ -390,7 +390,7 @@ class FusedAPIImpl @Inject constructor( if (status != ResultStatus.OK) { return ResultSupreme.create(status, Pair(packageSpecificResults, true)) } return null return ResultSupreme.create(status, Pair(packageSpecificResults, false)) } /* Loading @@ -413,31 +413,29 @@ class FusedAPIImpl @Inject constructor( private suspend fun getCleanApkPackageResult( query: String, cleanapkPackageResult: FusedApp? ) { var cleanapkPackageResultReference = cleanapkPackageResult ): FusedApp? { getCleanapkSearchResult(query).let { if (it.isSuccess() && it.data!!.package_name.isNotBlank()) { cleanapkPackageResultReference = it.data!! return it.data!! } } return null } private suspend fun getGplayPackagResult( query: String, authData: AuthData, gplayPackageResult: FusedApp? ) { var gplayPackageResultReference = gplayPackageResult ): FusedApp? { try { getApplicationDetails(query, query, authData, Origin.GPLAY).let { if (it.second == ResultStatus.OK) { gplayPackageResultReference = it.first return it.first } } } catch (e: Exception) { Timber.e(e) } return null } /* Loading app/src/main/java/foundation/e/apps/utils/modules/PreferenceManagerModule.kt +2 −0 Original line number Diff line number Diff line Loading @@ -21,10 +21,12 @@ package foundation.e.apps.utils.modules import android.content.Context import androidx.preference.PreferenceManager import dagger.hilt.android.qualifiers.ApplicationContext import foundation.e.apps.OpenForTesting import javax.inject.Inject import javax.inject.Singleton @Singleton @OpenForTesting class PreferenceManagerModule @Inject constructor( @ApplicationContext private val context: Context ) { Loading app/src/main/res/layout/home_parent_list_item.xml +8 −7 Original line number Diff line number Diff line Loading @@ -43,17 +43,18 @@ <TextView android:id="@+id/categoryTag" android:background="@drawable/bg_tag_rounded" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_marginEnd="15dp" android:background="@drawable/bg_tag_rounded" android:paddingStart="6dp" android:paddingTop="2dp" android:paddingEnd="6dp" android:paddingBottom="2dp" android:textAllCaps="false" android:textColor="#626262" android:textSize="15sp" android:paddingTop="2dp" android:paddingBottom="2dp" android:paddingStart="6dp" android:paddingEnd="6dp" android:layout_alignParentEnd="true" android:visibility="gone" tools:text="Open Source" /> Loading app/src/test/java/foundation/e/apps/FakePreferenceModule.kt 0 → 100644 +47 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 ECORP * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package foundation.e.apps import android.content.Context import foundation.e.apps.utils.modules.PreferenceManagerModule class FakePreferenceModule(context: Context) : PreferenceManagerModule(context) { var isPWASelectedFake = false var isOpenSourceelectedFake = false var isGplaySelectedFake = false override fun isPWASelected(): Boolean { return isPWASelectedFake } override fun isOpenSourceSelected(): Boolean { return isOpenSourceelectedFake } override fun isGplaySelected(): Boolean { return isGplaySelectedFake } override fun preferredApplicationType(): String { return when { isOpenSourceelectedFake -> "open" isPWASelectedFake -> "pwa" else -> "any" } } } No newline at end of file Loading
app/build.gradle +1 −2 Original line number Diff line number Diff line Loading @@ -135,8 +135,7 @@ dependencies { // Optional -- mockito-kotlin testImplementation "org.mockito.kotlin:mockito-kotlin:3.2.0" testImplementation 'org.mockito:mockito-inline:2.13.0' testImplementation "androidx.arch.core:core-testing:2.1.0" // Coil and PhotoView implementation "io.coil-kt:coil:1.4.0" Loading
app/src/main/java/foundation/e/apps/api/fused/FusedAPIImpl.kt +9 −11 Original line number Diff line number Diff line Loading @@ -365,11 +365,11 @@ class FusedAPIImpl @Inject constructor( val status = runCodeBlockWithTimeout({ if (preferenceManagerModule.isGplaySelected()) { getGplayPackagResult(query, authData, gplayPackageResult) gplayPackageResult = getGplayPackagResult(query, authData) } if (preferenceManagerModule.isOpenSourceSelected()) { getCleanApkPackageResult(query, cleanapkPackageResult) cleanapkPackageResult = getCleanApkPackageResult(query) } }) Loading @@ -390,7 +390,7 @@ class FusedAPIImpl @Inject constructor( if (status != ResultStatus.OK) { return ResultSupreme.create(status, Pair(packageSpecificResults, true)) } return null return ResultSupreme.create(status, Pair(packageSpecificResults, false)) } /* Loading @@ -413,31 +413,29 @@ class FusedAPIImpl @Inject constructor( private suspend fun getCleanApkPackageResult( query: String, cleanapkPackageResult: FusedApp? ) { var cleanapkPackageResultReference = cleanapkPackageResult ): FusedApp? { getCleanapkSearchResult(query).let { if (it.isSuccess() && it.data!!.package_name.isNotBlank()) { cleanapkPackageResultReference = it.data!! return it.data!! } } return null } private suspend fun getGplayPackagResult( query: String, authData: AuthData, gplayPackageResult: FusedApp? ) { var gplayPackageResultReference = gplayPackageResult ): FusedApp? { try { getApplicationDetails(query, query, authData, Origin.GPLAY).let { if (it.second == ResultStatus.OK) { gplayPackageResultReference = it.first return it.first } } } catch (e: Exception) { Timber.e(e) } return null } /* Loading
app/src/main/java/foundation/e/apps/utils/modules/PreferenceManagerModule.kt +2 −0 Original line number Diff line number Diff line Loading @@ -21,10 +21,12 @@ package foundation.e.apps.utils.modules import android.content.Context import androidx.preference.PreferenceManager import dagger.hilt.android.qualifiers.ApplicationContext import foundation.e.apps.OpenForTesting import javax.inject.Inject import javax.inject.Singleton @Singleton @OpenForTesting class PreferenceManagerModule @Inject constructor( @ApplicationContext private val context: Context ) { Loading
app/src/main/res/layout/home_parent_list_item.xml +8 −7 Original line number Diff line number Diff line Loading @@ -43,17 +43,18 @@ <TextView android:id="@+id/categoryTag" android:background="@drawable/bg_tag_rounded" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentEnd="true" android:layout_marginEnd="15dp" android:background="@drawable/bg_tag_rounded" android:paddingStart="6dp" android:paddingTop="2dp" android:paddingEnd="6dp" android:paddingBottom="2dp" android:textAllCaps="false" android:textColor="#626262" android:textSize="15sp" android:paddingTop="2dp" android:paddingBottom="2dp" android:paddingStart="6dp" android:paddingEnd="6dp" android:layout_alignParentEnd="true" android:visibility="gone" tools:text="Open Source" /> Loading
app/src/test/java/foundation/e/apps/FakePreferenceModule.kt 0 → 100644 +47 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 ECORP * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ package foundation.e.apps import android.content.Context import foundation.e.apps.utils.modules.PreferenceManagerModule class FakePreferenceModule(context: Context) : PreferenceManagerModule(context) { var isPWASelectedFake = false var isOpenSourceelectedFake = false var isGplaySelectedFake = false override fun isPWASelected(): Boolean { return isPWASelectedFake } override fun isOpenSourceSelected(): Boolean { return isOpenSourceelectedFake } override fun isGplaySelected(): Boolean { return isGplaySelectedFake } override fun preferredApplicationType(): String { return when { isOpenSourceelectedFake -> "open" isPWASelectedFake -> "pwa" else -> "any" } } } No newline at end of file