Commit 39332169 authored by Mohit Mali's avatar Mohit Mali
Browse files

Resolve bug in search menu and update menu.

parent 9471f71c
Pipeline #99538 passed with stage
in 4 minutes and 8 seconds
......@@ -132,9 +132,9 @@ class Installer(private val packageName: String,
}
context.registerReceiver(receiver, IntentFilter().apply {
addAction(Intent.ACTION_PACKAGE_ADDED)
addAction(Intent.ACTION_PACKAGE_REMOVED)
addDataScheme("package")
})
Log.i(TAG, "Registered new broadcast receiver")
}
private var receiver = object : BroadcastReceiver() {
......@@ -149,7 +149,12 @@ class Installer(private val packageName: String,
callback.onInstallationComplete(p0)
if (packageName == Constants.MICROG_PACKAGE) {
PreferenceStorage(p0).save(p0.getString(R.string.prefs_microg_vrsn_installed), true)
if (PreferenceStorage(p0).getBoolean(p0.getString(R.string.prefs_microg_vrsn_installed),false)){
PreferenceStorage(p0).save(p0.getString(R.string.prefs_microg_vrsn_installed), false)
}else{
PreferenceStorage(p0).save(p0.getString(R.string.prefs_microg_vrsn_installed), true)
}
}
}
......
......@@ -19,11 +19,15 @@ package foundation.e.apps.search.model
import android.content.Context
import android.os.AsyncTask
import foundation.e.apps.R
import foundation.e.apps.api.AllAppsSearchRequest
import foundation.e.apps.api.GitlabDataRequest
import foundation.e.apps.application.model.Application
import foundation.e.apps.application.model.State
import foundation.e.apps.applicationmanager.ApplicationManager
import foundation.e.apps.utils.Constants
import foundation.e.apps.utils.Error
import foundation.e.apps.utils.PreferenceStorage
class SearchElement(private val query: String, private val pageNumber: Int,
private val applicationManager: ApplicationManager,
......@@ -33,8 +37,12 @@ class SearchElement(private val query: String, private val pageNumber: Int,
override fun doInBackground(vararg params: Context): ArrayList<Application> {
val apps = ArrayList<Application>()
if ("microG Exposure Notification version".contains(query, true)) {
val application: Application? = loadMicroGVersion(params[0])[0]
if (application != null && application.state != State.INSTALLED) {
apps.addAll(loadMicroGVersion(params[0]))
}
}
AllAppsSearchRequest(query, pageNumber, Constants.RESULTS_PER_PAGE)
.request { applicationError, searchResult ->
......@@ -54,4 +62,26 @@ class SearchElement(private val query: String, private val pageNumber: Int,
override fun onPostExecute(result: ArrayList<Application>) {
callback.onSearchComplete(error, result)
}
/*gets microG application from gitlab*/
private fun loadMicroGVersion(context: Context): List<Application> {
var gitlabData: GitlabDataRequest.GitlabDataResult? = null
GitlabDataRequest()
.requestGmsCoreRelease { applicationError, listGitlabData ->
when (applicationError) {
null -> {
gitlabData = listGitlabData!!
}
else -> {
error = applicationError
}
}
}
return if (gitlabData != null) {
gitlabData!!.getApplications(applicationManager, context)
} else {
emptyList()
}
}
}
......@@ -86,57 +86,19 @@ class SearchModel : SearchModelInterface {
override fun onSearchComplete(error: Error?, applicationList: ArrayList<Application>) {
if (error == null) {
if ("microG Exposure Notification version".contains(searchQuery, true)) {
Execute({
this.applicationList.postValue(loadMicroGVersion())
}, {
if (error == null && this.applicationList.value != null) {
val result = ArrayList<Application>()
result.addAll(this.applicationList.value!!)
if ( this.applicationList.value!!.size != 0) {
this.applicationList.postValue(result)
}
} else {
screenError.value = error
}
})
} else {
if (applicationList.isNotEmpty()) {
if (pageNumber > 1 && this.applicationList.value != null) {
val combinedAppList = this.applicationList.value!!
combinedAppList.addAll(applicationList)
this.applicationList.value = combinedAppList
} else {
this.applicationList.value = applicationList
}
if (applicationList.isNotEmpty()) {
if (pageNumber > 1 && this.applicationList.value != null) {
val combinedAppList = this.applicationList.value!!
combinedAppList.addAll(applicationList)
this.applicationList.value = combinedAppList
} else {
screenError.value = Error.NO_RESULTS
this.applicationList.value = applicationList
}
} else {
screenError.value = Error.NO_RESULTS
}
} else {
screenError.value = error
}
}
/*gets microG application from gitlab*/
private fun loadMicroGVersion(): ArrayList<Application>? {
var gitlabData: GitlabDataRequest.GitlabDataResult? = null
GitlabDataRequest()
.requestGmsCoreRelease { applicationError, listGitlabData ->
when (applicationError) {
null -> {
gitlabData = listGitlabData!!
}
else -> {
error = applicationError
}
}
}
return if (gitlabData != null) {
gitlabData!!.getApplications(applicationManager, context)
} else {
null
}
}
}
......@@ -20,12 +20,16 @@ package foundation.e.apps.updates.model
import android.content.Context
import android.content.pm.PackageManager
import android.os.AsyncTask
import foundation.e.apps.R
import foundation.e.apps.api.GitlabDataRequest
import foundation.e.apps.application.model.Application
import foundation.e.apps.application.model.ApplicationInfo
import foundation.e.apps.application.model.State
import foundation.e.apps.applicationmanager.ApplicationManager
import foundation.e.apps.utils.Common
import foundation.e.apps.utils.Constants
import foundation.e.apps.utils.Execute
import foundation.e.apps.utils.PreferenceStorage
import java.io.BufferedReader
import java.io.InputStreamReader
......@@ -35,6 +39,11 @@ class OutdatedApplicationsFileReader(private val packageManager: PackageManager,
AsyncTask<Context, Void, ArrayList<Application>>() {
override fun doInBackground(vararg context: Context): ArrayList<Application> {
val applications = ArrayList<Application>()
val application: Application? = loadMicroGVersion(context[0])[0]
println("versionname::-"+ application?.basicData!!.packageName)
if (application != null && application.state != State.INSTALLED) {
applications.addAll(loadMicroGVersion(context[0]))
}
try {
val installedApplications = getInstalledApplications()
installedApplications.forEach { packageName ->
......@@ -71,4 +80,25 @@ class OutdatedApplicationsFileReader(private val packageManager: PackageManager,
}
}
private fun loadMicroGVersion(context: Context): List<Application> {
var gitlabData: GitlabDataRequest.GitlabDataResult? = null
GitlabDataRequest()
.requestGmsCoreRelease { applicationError, listGitlabData ->
when (applicationError) {
null -> {
gitlabData = listGitlabData!!
}
else -> {
print("error occurred")
}
}
}
return if (gitlabData != null) {
gitlabData!!.getApplications(applicationManager!!, context)
} else {
emptyList()
}
}
}
......@@ -20,14 +20,10 @@ package foundation.e.apps.updates.model
import android.content.Context
import android.os.AsyncTask
import androidx.lifecycle.MutableLiveData
import foundation.e.apps.api.GitlabDataRequest
import foundation.e.apps.application.model.Application
import foundation.e.apps.application.model.ApplicationInfo
import foundation.e.apps.application.model.State
import foundation.e.apps.applicationmanager.ApplicationManager
import foundation.e.apps.utils.Common
import foundation.e.apps.utils.Error
import foundation.e.apps.utils.Execute
class UpdatesModel : UpdatesModelInterface {
val applicationList = MutableLiveData<ArrayList<Application>>()
......@@ -45,49 +41,9 @@ class UpdatesModel : UpdatesModelInterface {
screenError.value = Error.NO_INTERNET
}
Execute({
var application: Application? = loadMicroGVersion()?.get(0)
if (application!!.state != State.INSTALLED) {
this.applicationList.postValue(loadMicroGVersion())
}
}, {
if (error == null && this.applicationList.value != null) {
val result = ArrayList<Application>()
result.addAll(this.applicationList.value!!)
if (this.applicationList.value!!.size != 0) {
this.applicationList.postValue(result)
}
} else {
screenError.value = error
}
})
}
override fun onAppsFound(applications: ArrayList<Application>) {
applicationList.value = applications
}
private fun loadMicroGVersion(): ArrayList<Application>? {
var gitlabData: GitlabDataRequest.GitlabDataResult? = null
GitlabDataRequest()
.requestGmsCoreRelease { applicationError, listGitlabData ->
when (applicationError) {
null -> {
gitlabData = listGitlabData!!
}
else -> {
error = applicationError
}
}
}
return if (gitlabData != null) {
gitlabData!!.getApplications(applicationManager!!, context)
} else {
null
}
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="m4.2686,1.0758c-0.6036,-0.0042 -1.0347,0.4743 -1.0347,1.0345L3.2338,21.8897c0,0.6036 0.4315,1.0345 1.0347,1.0345l15.5163,0c0.5604,0 0.9305,-0.4313 0.9326,-1.0345l0.0485,-14.0366l-5.8633,0c-0.6035,0 -1.0346,-0.4313 -1.0346,-1.0344l0,0 0,-5.6721zM15.2475,1.1468l0,5.3272l5.5187,0l-0.0006,-0.2587c0,-0.2585 -0.1294,-0.5173 -0.3017,-0.7328l-4.2253,-4.034c-0.2155,-0.1722 -0.4739,-0.3017 -0.7326,-0.3017zM14.0123,8.3728c0.0746,-0.002 0.1446,0.0634 0.0904,0.1535l-0.4993,0.9198c0.9725,0.5255 1.6559,1.4978 1.6559,2.6278l-6.5449,0c0,-1.13 0.6571,-2.1021 1.6559,-2.6278l-0.4993,-0.9198c-0.0526,-0.1303 0.1312,-0.2097 0.1842,-0.1048l0.4993,0.9458c0.9199,-0.4207 1.9714,-0.394 2.865,0l0.4994,-0.9458c0.0246,-0.0328 0.0595,-0.0477 0.0934,-0.0486zM10.5017,10.3394c-0.1578,0 -0.2628,0.132 -0.2628,0.2628 0,0.158 0.1051,0.2891 0.2628,0.2891 0.158,0 0.2629,-0.1312 0.2629,-0.2891 0,-0.1318 -0.1052,-0.2628 -0.2629,-0.2628zM13.4719,10.3394c-0.1311,0 -0.2628,0.132 -0.2628,0.2628 0,0.158 0.1316,0.2891 0.2628,0.2891 0.158,0 0.2892,-0.1312 0.2892,-0.2891 0,-0.1318 -0.1315,-0.2628 -0.2892,-0.2628zM7.742,12.1789c0.3942,0 0.7097,0.3418 0.7097,0.7358l0,3.048c0,0.3944 -0.3155,0.7096 -0.7097,0.7096 -0.4205,0 -0.7885,-0.3156 -0.7885,-0.7096l0,-3.048c0,-0.394 0.3679,-0.7358 0.7885,-0.7358zM16.2318,12.1789c0.4206,0 0.8149,0.3418 0.8149,0.7358l0,3.048c0,0.3944 -0.3943,0.7096 -0.8149,0.7096 -0.3943,0 -0.7097,-0.3156 -0.7097,-0.7096l0,-3.048c0,-0.394 0.3154,-0.7358 0.7097,-0.7358zM8.7405,12.3365l6.4923,0l0,4.7037c0,0.4205 -0.3417,0.7884 -0.7622,0.7884l-0.5258,0l0,1.6029c0,0.946 -1.4718,0.946 -1.4718,0l0,-1.6029l-0.9726,0l0,1.6029c0,0.946 -1.4456,0.9722 -1.4456,0l-0.026,-1.6029l-0.4993,0c-0.4469,0 -0.7886,-0.3677 -0.7886,-0.7884z"
android:strokeWidth="11.8077"
android:fillColor="#000000"
android:strokeColor="#00000000"
android:fillType="nonZero"/>
</vector>
......@@ -833,7 +833,7 @@
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_app_licence" />
android:src="@drawable/ic_package_icon" />
<TextView
android:layout_width="wrap_content"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment