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

Commit 0415c3ab authored by Mohit Mali's avatar Mohit Mali Committed by Romain Hunault
Browse files

Make System app available to be be downloaded from app store

parent efee6602
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -21,6 +21,9 @@ android {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug{
            applicationIdSuffix ".debug"
        }
    }
    dataBinding {
        enabled = true
@@ -87,6 +90,8 @@ dependencies {
    implementation "com.fasterxml.jackson.core:jackson-databind:2.11.1"
    implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.11.1"

    implementation 'com.android.volley:volley:1.1.1'

    implementation 'com.github.chrisbanes:PhotoView:2.3.0'

    compileOnly files("e-ui-sdk.jar")
+1 −2
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
    companion object {
        lateinit var mActivity: MainActivity
        var sharedPreferences : SharedPreferences?=null

        val sharedPrefFile = "kotlinsharedpreference"
    }


@@ -88,7 +88,6 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
        disableCategoryIfOpenSource()



        bottom_navigation_view.setOnNavigationItemSelectedListener{
            if (selectFragment(it.itemId,it)) {
                disableCategoryIfOpenSource()
+58 −0
Original line number Diff line number Diff line
@@ -18,39 +18,21 @@
package foundation.e.apps.api

import android.content.Context
import android.util.Log
import android.view.View
import com.android.volley.Request
import com.android.volley.Response
import com.android.volley.toolbox.StringRequest
import com.android.volley.toolbox.Volley
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty
import com.google.gson.Gson
import com.google.gson.JsonParser
import foundation.e.apps.MainActivity.Companion.mActivity
import foundation.e.apps.application.model.Application
import foundation.e.apps.application.model.data.BasicData
import foundation.e.apps.application.model.release.ReleaseData
import foundation.e.apps.applicationmanager.ApplicationManager
import foundation.e.apps.utils.ApplicationParser
import foundation.e.apps.utils.Common
import foundation.e.apps.utils.Constants
import foundation.e.apps.utils.Error
import kotlinx.android.synthetic.main.activity_category.*
import java.io.BufferedReader
import foundation.e.apps.utils.*
import java.io.InputStreamReader
import java.net.URLEncoder

class MicroGDataRequest {
class GitlabDataRequest {

    companion object {
        private val reader = Common.getObjectMapper().readerFor(MicroGDataRequest::class.java)
    }

    fun requestGmsCoreRelease(callback: (Error?, MicroGDataRequest?) -> Unit) {
    fun requestGmsCoreRelease(callback: (Error?, GitlabDataResult?) -> Unit) {
        try {
            val url = Constants.GMS_RELEASE_API
            val url = Constants.RELEASE_API + Constants.MICROG_ID + Constants.RELEASE_ENDPOINT
            val urlConnection = Common.createConnection(url, Constants.REQUEST_METHOD_GET)
            val isr = InputStreamReader(urlConnection.inputStream)
            val element = JsonParser().parse(isr)
@@ -58,36 +40,15 @@ class MicroGDataRequest {
            val releaseList: List<ReleaseData> = Gson().fromJson(element.toString(),
                    Array<ReleaseData>::class.java).toList()


            val basicData = BasicData(
                    id = "1",
                    name = "MicroG",
                    packageName = Constants.MICROG_PACKAGE,
                    lastVersionNumber = releaseList[0].tag_name,
                    lastVersionCode = 0,
                    latestDownloadableUpdate = "",
                    armeabi_latestDownloadableUpdate = "",
                    arm64_v8a_latest_latestDownloadableUpdate = "",
                    x86_latestDownloadableUpdate = "",
                    armeabi_v7a_latestDownloadableUpdate = "",
                    apkArchitecture = ArrayList(),
                    author = "e-Foundation",
                    iconUri = "https://gitlab.e.foundation/uploads/-/system/project/avatar/149/ic_core_service_app.png?width=64",
                    imagesUri = arrayOf(),
                    privacyRating = 0f,
                    ratings = BasicData.Ratings(0f, 0f),
                    category = "System Apps",
                    is_pwa = false,
                    x86_64_latestDownloadableUpdate = ""
            )
            urlConnection.disconnect()
            callback.invoke(null, MicroGDataRequest(basicData))
            callback.invoke(null, GitlabDataResult(SystemAppDataSource.createDataSource(Constants.MICROG_ID.toString(),
                    releaseList[0].tag_name, Constants.MICROG_ICON_URI)))
        } catch (e: Exception) {
            callback.invoke(Error.findError(e), null)
        }
    }

    class MicroGDataRequest(private val data: BasicData) {
    class GitlabDataResult(private val data: BasicData) {
        fun getApplications(applicationManager: ApplicationManager, context: Context): ArrayList<Application> {
            return ApplicationParser.parseSystemAppData(applicationManager, context, data)
        }
+0 −42
Original line number Diff line number Diff line
/*
    Copyright (C) 2019  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.api

import com.fasterxml.jackson.annotation.JsonCreator
import foundation.e.apps.utils.Common
import foundation.e.apps.utils.Constants

class SystemAppDownloadedRequest(private val id: String) {
    companion object {
        private val reader = Common.getObjectMapper().readerFor(Result::class.java)
    }

    fun request() {
        try {
            val url = Constants.SYSTEM_APP_DOWNLOAD_URL + Constants.GMS_ID + "/jobs/artifacts/$id/raw/play-services-core/build/outputs/apk/release/play-services-core-release-unsigned.apk?job=build"
            val urlConnection = Common.createConnection(url, Constants.REQUEST_METHOD_GET)
            reader.readValue<Result>(urlConnection.inputStream)
            urlConnection.disconnect()
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    class Result @JsonCreator
    constructor()
}
+2 −1
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ class ApplicationViewHolder(private val activity: Activity, private val view: Vi
        pwa_icon.visibility = View.GONE
        view.setOnClickListener {
            if (application != null) {
                if (application!!.packageName != Constants.MICROG_PACKAGE)
                    applicationViewModel.onApplicationClick(view.context, application!!)
            }
        }
Loading