Commit 1c853dca authored by Nihar Thakkar's avatar Nihar Thakkar

Merge branch 'implement-app_download_request' into 'master'

Implement app download request

See merge request !9
parents 2b4b8e80 67b09ca2
Pipeline #17692 passed with stage
in 3 minutes and 1 second
......@@ -10,8 +10,8 @@ android {
applicationId "foundation.e.apps"
minSdkVersion 21
targetSdkVersion 27
versionCode 7
versionName "1.1.4"
versionCode 8
versionName "1.1.5"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
......
/*
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 com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.databind.ObjectMapper
import foundation.e.apps.utils.Common
import foundation.e.apps.utils.Constants
class AppDownloadedRequest(private val id: String) {
companion object {
private val reader = ObjectMapper().readerFor(Result::class.java)
}
fun request() {
try {
val url = Constants.BASE_URL + "apps?action=download&app_id=$id"
val urlConnection = Common.createConnection(url, Constants.REQUEST_METHOD_GET)
reader.readValue<Result>(urlConnection.inputStream)
urlConnection.disconnect()
} catch (e: Exception) {
e.printStackTrace()
}
}
class Result @JsonCreator @JsonIgnoreProperties(ignoreUnknown = true)
constructor()
}
......@@ -22,8 +22,8 @@ import android.app.Activity
import android.app.DownloadManager
import android.content.Context
import android.content.pm.PackageManager
import android.widget.ImageView
import foundation.e.apps.api.AppDetailRequest
import foundation.e.apps.api.AppDownloadedRequest
import foundation.e.apps.api.PackageNameSearchRequest
import foundation.e.apps.application.model.State.*
import foundation.e.apps.application.model.data.BasicData
......@@ -32,6 +32,7 @@ import foundation.e.apps.applicationmanager.ApplicationManager
import foundation.e.apps.utils.Common
import foundation.e.apps.utils.Constants
import foundation.e.apps.utils.Error
import foundation.e.apps.utils.Execute
import java.util.concurrent.atomic.AtomicInteger
class Application(val packageName: String, private val applicationManager: ApplicationManager) :
......@@ -152,6 +153,9 @@ class Application(val packageName: String, private val applicationManager: Appli
override fun onDownloadComplete(context: Context, status: Int) {
if (status == DownloadManager.STATUS_SUCCESSFUL) {
Execute({
AppDownloadedRequest(basicData!!.id).request()
}, {})
install(context)
} else {
synchronized(blocker) {
......
Markdown is supported
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