Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Verified Commit 2df152f1 authored by Fahim M. Choudhury's avatar Fahim M. Choudhury
Browse files

refactor: introduce SearchSuggestion data class independent of GPlay API

parent 5a438110
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
/*
 * Apps  Quickly and easily install Android apps onto your device!
 * Copyright (C) 2021  E FOUNDATION
 * Copyright (C) 2021-2025 e Foundation
 *
 * 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
@@ -14,29 +13,30 @@
 *
 * 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.data.application

import androidx.lifecycle.LiveData
import com.aurora.gplayapi.SearchSuggestEntry
import com.aurora.gplayapi.data.models.AuthData
import foundation.e.apps.data.ResultSupreme
import foundation.e.apps.data.application.apps.AppsApi
import foundation.e.apps.data.application.category.CategoryApi
import foundation.e.apps.data.enums.FilterLevel
import foundation.e.apps.data.enums.ResultStatus
import foundation.e.apps.data.enums.Source
import foundation.e.apps.data.enums.Status
import foundation.e.apps.data.application.data.Application
import foundation.e.apps.data.application.data.Category
import foundation.e.apps.data.application.data.Home
import foundation.e.apps.data.application.downloadInfo.DownloadInfoApi
import foundation.e.apps.data.application.home.HomeApi
import foundation.e.apps.data.application.search.SearchRepository
import foundation.e.apps.data.application.search.SearchResult
import foundation.e.apps.data.application.search.SearchSuggestion
import foundation.e.apps.data.application.utils.CategoryType
import foundation.e.apps.data.enums.FilterLevel
import foundation.e.apps.data.enums.ResultStatus
import foundation.e.apps.data.enums.Source
import foundation.e.apps.data.enums.Status
import foundation.e.apps.data.install.models.AppInstall
import foundation.e.apps.data.application.search.SearchResult
import javax.inject.Inject
import javax.inject.Singleton

@@ -104,7 +104,7 @@ class ApplicationRepository @Inject constructor(
        return categoryApi.getCategoriesList(type)
    }

    suspend fun getSearchSuggestions(query: String): List<SearchSuggestEntry> {
    suspend fun getSearchSuggestions(query: String): List<SearchSuggestion> {
        return searchRepository.getSearchSuggestions(query)
    }

+3 −6
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 e Foundation
 * Copyright MURENA SAS 2023
 * Apps  Quickly and easily install Android apps onto your device!
 *
 * 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
@@ -14,17 +14,14 @@
 *
 * 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.data.application.search

import com.aurora.gplayapi.SearchSuggestEntry
import com.aurora.gplayapi.data.models.SearchBundle
import foundation.e.apps.data.ResultSupreme
import foundation.e.apps.data.application.data.Application

typealias GplaySearchResult = ResultSupreme<Pair<List<Application>, Set<SearchBundle.SubBundle>>>

typealias SearchResult = ResultSupreme<Pair<List<Application>, Boolean>>

interface SearchRepository {
@@ -50,5 +47,5 @@ interface SearchRepository {
        query: String,
    ): SearchResult

    suspend fun getSearchSuggestions(query: String): List<SearchSuggestEntry>
    suspend fun getSearchSuggestions(query: String): List<SearchSuggestion>
}
+5 −5
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024-2025 e Foundation
 * Copyright (C) 2024 MURENA SAS
 *
 * This program is free software: you can redistribute it and/or modify
@@ -19,7 +20,6 @@
package foundation.e.apps.data.application.search

import android.content.Context
import com.aurora.gplayapi.SearchSuggestEntry
import com.aurora.gplayapi.data.models.SearchBundle
import dagger.hilt.android.qualifiers.ApplicationContext
import foundation.e.apps.data.AppSourcesContainer
@@ -280,13 +280,13 @@ class SearchRepositoryImpl @Inject constructor(
        return ResultSupreme.create(result.getResultStatus(), application)
    }

    override suspend fun getSearchSuggestions(query: String): List<SearchSuggestEntry> {
        var searchSuggesions = listOf<SearchSuggestEntry>()
    override suspend fun getSearchSuggestions(query: String): List<SearchSuggestion> {
        var searchSuggestions = listOf<SearchSuggestion>()
        handleNetworkResult {
            searchSuggesions = appSources.gplayRepo.getSearchSuggestions(query)
            searchSuggestions = appSources.gplayRepo.getSearchSuggestions(query)
        }

        return searchSuggesions
        return searchSuggestions
    }

    private suspend fun getCleanAPKSearchResults(
+26 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 e Foundation
 *
 * 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.data.application.search

import foundation.e.apps.data.enums.Source

data class SearchSuggestion(
    val suggestion: String,
    val source: Source
)
+2 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 e Foundation
 * Copyright MURENA SAS 2023
 * Apps  Quickly and easily install Android apps onto your device!
 *
 * 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
@@ -14,6 +14,7 @@
 *
 * 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.data.cleanapk.repositories
Loading