Commit 24107a8d authored by Aayush Gupta's avatar Aayush Gupta
Browse files

Apps: Bump to v1.3.0

parent 6374a3af
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
id 'kotlin-parcelize'
}
android {
compileSdkVersion 29
buildToolsVersion '29.0.2'
compileSdkVersion 30
buildToolsVersion '30.0.3'
defaultConfig {
applicationId "foundation.e.apps"
minSdkVersion 25
targetSdkVersion 29
versionCode 10
versionName "1.2.0"
versionName "1.3.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
signingConfigs {
......@@ -47,9 +46,7 @@ android {
lintOptions {
lintConfig file("lint.xml")
disable 'MissingTranslation'
}
androidExtensions {
experimental = true
disable 'NullSafeMutableLiveData'
}
aaptOptions {
additionalParameters '-I', 'app/e-ui-sdk.jar'
......@@ -81,41 +78,25 @@ dependencies {
// Preference
implementation "androidx.preference:preference-ktx:1.1.1"
// Lifecycle
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
// Bouncy Castle
implementation 'org.bouncycastle:bcpg-jdk15on:1.60'
// GSON
implementation 'com.google.code.gson:gson:2.8.6'
// EventBus
implementation 'org.greenrobot:eventbus:3.2.0'
// Volley
implementation "com.android.volley:volley:1.2.0"
// PhotoView
implementation "com.github.chrisbanes:PhotoView:2.3.0"
// RoundedImageView
implementation "com.makeramen:roundedimageview:2.3.0"
// RecyclerView
implementation 'androidx.recyclerview:recyclerview:1.2.0'
// WorkManager
implementation 'androidx.work:work-runtime:2.5.0'
implementation 'androidx.work:work-runtime-ktx:2.5.0'
// Android-Iconics
implementation 'com.mikepenz:iconics-core:3.1.0@aar'
implementation 'com.mikepenz:google-material-typeface:3.0.1.2.original@aar'
// Vectordrawable
def vector_version = "1.1.0"
implementation "androidx.vectordrawable:vectordrawable:$vector_version"
implementation "androidx.vectordrawable:vectordrawable-animated:$vector_version"
// Lifecycle
def lifecycle_version = "2.3.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
// Navigation component
def nav_version = "2.3.5"
......
......@@ -75,6 +75,13 @@
android:launchMode="singleInstance"
android:theme="@style/AppTheme1"
android:windowSoftInputMode="adjustResize" />
<receiver android:name=".updates.UpdatesManager">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
</application>
</manifest>
\ No newline at end of file
......@@ -52,7 +52,7 @@ import foundation.e.apps.updates.UpdatesManager
import foundation.e.apps.utils.Common
import foundation.e.apps.utils.Constants
import foundation.e.apps.utils.Constants.CURRENTLY_SELECTED_FRAGMENT_KEY
import kotlin.properties.Delegates
class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemSelectedListener,
ApplicationManagerServiceConnectionCallback {
......@@ -67,7 +67,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
private val codeRequestPermissions = 9527
var doubleBackToExitPressedOnce = false;
private var isReceiverRegistered = false
var accentColorOS = 0
private var accentColorOS by Delegates.notNull<Int>()
init {
instance = this
......@@ -96,6 +96,9 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
super.onCreate(savedInstanceState)
setContentView(binding.root)
accentColorOS = Common.getAccentColor(this)
mActivity = this
disableCategoryIfOpenSource()
......@@ -114,9 +117,6 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
Common.updateMicroGStatus(this)
initialiseUpdatesWorker()
// Show the home fragment by default
currentFragmentId = if (savedInstanceState != null &&
savedInstanceState.containsKey(CURRENTLY_SELECTED_FRAGMENT_KEY)) {
......@@ -129,7 +129,6 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
setupLangReceiver()
applicationManagerServiceConnection.bindService(this)
getAccentColor();
bottom_navigation_view_color()
openSearchFragment()
}
......@@ -168,12 +167,6 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
}
private fun initialiseUpdatesWorker() {
UpdatesManager(applicationContext).startWorker()
}
override fun onServiceBind(applicationManager: ApplicationManager) {
initialiseFragments(applicationManager)
selectFragment(currentFragmentId, null)
......@@ -341,17 +334,4 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
}
}, 2000)
}
/*
* get Accent color from OS
*
* */
private fun getAccentColor() {
accentColorOS = this.getColor(R.color.colorAccent);
}
}
......@@ -19,7 +19,7 @@ package foundation.e.apps.XAPK
import android.annotation.SuppressLint
import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
import kotlinx.parcelize.Parcelize
@SuppressLint("ParcelCreator")
@Parcelize
......
......@@ -17,7 +17,6 @@
package foundation.e.apps.XAPK
import android.os.Environment
import foundation.e.apps.BuildConfig
import foundation.e.apps.MainActivity
import java.io.File
......
......@@ -18,7 +18,6 @@
package foundation.e.apps.XAPK
import android.os.Environment
import android.text.TextUtils
import foundation.e.apps.MainActivity
import java.io.File
......@@ -37,7 +36,7 @@ object FsUtils {
}
fun exists(filePath: String?): Boolean {
return !TextUtils.isEmpty(filePath) && exists(File(filePath))
return if (!filePath.isNullOrEmpty()) exists(File(filePath)) else false
}
fun exists(file: File?): Boolean {
......
......@@ -26,7 +26,7 @@ import android.os.Build
import android.os.Handler
import android.os.Looper
import androidx.annotation.RequiresApi
import com.makeramen.roundedimageview.BuildConfig
import foundation.e.apps.BuildConfig
import java.io.File
import java.io.FileInputStream
import java.io.IOException
......
......@@ -19,7 +19,6 @@ package foundation.e.apps.XAPK
import android.content.Context
import android.content.Intent
import android.os.Build
import java.io.File
object IntentUtils {
......
......@@ -17,7 +17,6 @@
package foundation.e.apps.XAPK
import android.os.Build
import android.os.LocaleList
import android.text.TextUtils
import java.util.*
......
......@@ -19,7 +19,6 @@ package foundation.e.apps.XAPK
import android.content.Context
import android.net.Uri
import android.os.Build
import androidx.core.content.FileProvider
import foundation.e.apps.BuildConfig
import java.io.File
......
......@@ -17,7 +17,6 @@
package foundation.e.apps.XAPK
import android.os.Build
import android.os.Handler
import android.os.Looper
import androidx.annotation.MainThread
......
......@@ -19,7 +19,7 @@ package foundation.e.apps.api
import android.content.Context
import com.google.gson.Gson
import com.google.gson.JsonParser
import com.google.gson.JsonParser.parseReader
import foundation.e.apps.application.model.Application
import foundation.e.apps.application.model.data.BasicData
import foundation.e.apps.application.model.release.ReleaseData
......@@ -35,7 +35,7 @@ class GitlabDataRequest {
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)
val element = parseReader(isr)
val releaseList: List<ReleaseData> = Gson().fromJson(element.toString(),
Array<ReleaseData>::class.java).toList()
......
......@@ -24,6 +24,8 @@ import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.PorterDuff
import android.graphics.PorterDuffColorFilter
import android.os.Bundle
import android.os.CountDownTimer
import android.text.Html
......@@ -57,6 +59,7 @@ import foundation.e.apps.applicationmanager.ApplicationManager
import foundation.e.apps.applicationmanager.ApplicationManagerServiceConnection
import foundation.e.apps.applicationmanager.ApplicationManagerServiceConnectionCallback
import foundation.e.apps.categories.category.CategoryActivity
import foundation.e.apps.databinding.ActivityApplicationBinding
import foundation.e.apps.pwa.PwaInstaller
import foundation.e.apps.utils.Common
import foundation.e.apps.utils.Common.toMiB
......@@ -66,35 +69,38 @@ import foundation.e.apps.utils.Constants.APPLICATION_PACKAGE_NAME_KEY
import foundation.e.apps.utils.Constants.SELECTED_APPLICATION_SCREENSHOT_KEY
import foundation.e.apps.utils.Error
import foundation.e.apps.utils.Execute
import kotlinx.android.synthetic.main.activity_application.*
import kotlinx.android.synthetic.main.install_button_layout.*
import kotlin.math.roundToInt
class ApplicationActivity :
AppCompatActivity(),
ApplicationStateListener,
ApplicationManagerServiceConnectionCallback,
Downloader.DownloadProgressCallback,
BasicData.IconLoaderCallback,
PwasBasicData.IconLoaderCallback {
AppCompatActivity(),
ApplicationStateListener,
ApplicationManagerServiceConnectionCallback,
Downloader.DownloadProgressCallback,
BasicData.IconLoaderCallback,
PwasBasicData.IconLoaderCallback {
private lateinit var binding: ActivityApplicationBinding
private lateinit var applicationPackageName: String
private lateinit var application: Application
private val applicationManagerServiceConnection =
ApplicationManagerServiceConnection(this)
ApplicationManagerServiceConnection(this)
private var imageWidth = 0
private var imageHeight = 0
private var imageMargin = 0
private var defaultElevation = 0f
private val sharedPrefFile = "kotlinsharedpreference"
var accentColorOS = 0
override fun onCreate(savedInstanceState: Bundle?) {
binding = ActivityApplicationBinding.inflate(layoutInflater)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_application)
good_border.visibility = View.GONE
neutral_border.visibility = View.GONE
setContentView(binding.root)
val accentColorOS = Common.getAccentColor(this)
binding.goodBorder.visibility = View.GONE
binding.neutralBorder.visibility = View.GONE
val toolbar = findViewById<Toolbar>(R.id.toolbar)
......@@ -103,7 +109,7 @@ class ApplicationActivity :
supportActionBar?.setDisplayShowTitleEnabled(false)
sharedPreferences = this.getSharedPreferences(sharedPrefFile, Context.MODE_PRIVATE)
pwa_sympol.visibility = View.GONE
binding.pwaSympol.visibility = View.GONE
initialiseDimensions()
val applicationPackageName: String? = intent.getStringExtra(APPLICATION_PACKAGE_NAME_KEY)
......@@ -112,27 +118,28 @@ class ApplicationActivity :
applicationManagerServiceConnection.bindService(this)
}
getAccentColor()
app_install.setTextColor(Color.parseColor("#ffffff"))
app_install.setBackgroundColor(accentColorOS)
app_category.setTextColor(accentColorOS)
app_expand_description.setTextColor(accentColorOS)
// Set accent color
binding.installButtonLayout.appInstall.setTextColor(Color.parseColor("#ffffff"))
binding.installButtonLayout.appInstall.background.colorFilter = PorterDuffColorFilter(accentColorOS, PorterDuff.Mode.SRC_IN)
binding.appDownloadProgress.progressDrawable.colorFilter = PorterDuffColorFilter(accentColorOS, PorterDuff.Mode.SRC_IN)
binding.appCategory.setTextColor(accentColorOS)
binding.appExpandDescription.setTextColor(accentColorOS)
}
private fun initialiseElevation() {
if (scroll_view.scrollY == 0) {
toolbar.elevation = 0f
if (binding.scrollView.scrollY == 0) {
binding.toolbar.elevation = 0f
} else {
toolbar.elevation = defaultElevation
binding.toolbar.elevation = defaultElevation
}
scroll_view.setOnScrollChangeListener { view, _, _, _, _ ->
binding.scrollView.setOnScrollChangeListener { view, _, _, _, _ ->
if (view.scrollY == 0) {
toolbar.elevation = 0f
binding.toolbar.elevation = 0f
} else {
toolbar.elevation = defaultElevation
binding.toolbar.elevation = defaultElevation
}
}
}
......@@ -141,28 +148,28 @@ class ApplicationActivity :
application = applicationManager.findOrCreateApp(applicationPackageName)
var error: Error? = null
Execute({
error = application.assertFullData(this)
}, {
if (error == null) {
error = application.assertFullData(this)
}, {
if (error == null) {
onApplicationInfoLoaded()
} else {
Snackbar.make(container,
getString(error!!.description),
Snackbar.LENGTH_LONG).show()
// Close activity once snackbar has hidden
object : CountDownTimer(3500, 3500) {
override fun onTick(p0: Long) {
// Do nothing
}
onApplicationInfoLoaded()
} else {
Snackbar.make(binding.container,
getString(error!!.description),
Snackbar.LENGTH_LONG).show()
// Close activity once snackbar has hidden
object : CountDownTimer(3500, 3500) {
override fun onTick(p0: Long) {
// Do nothing
}
override fun onFinish() {
finish()
override fun onFinish() {
finish()
}
}.start()
}
}.start()
}
})
})
}
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
......@@ -170,8 +177,8 @@ class ApplicationActivity :
return true
}
override fun onOptionsItemSelected(item: MenuItem?): Boolean {
when (item?.itemId) {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
android.R.id.home -> {
finish()
}
......@@ -217,57 +224,56 @@ class ApplicationActivity :
// Set the app title
if (basicData.name.isNotEmpty()) {
app_title.text = basicData.name
binding.appTitle.text = basicData.name
} else {
app_title.visibility = View.GONE
binding.appTitle.visibility = View.GONE
}
// Set the app author
if (basicData.author.isNotEmpty()) {
app_author.text = basicData.author
binding.appAuthor.text = basicData.author
} else {
app_author.visibility = View.GONE
binding.appAuthor.visibility = View.GONE
}
// Set the app category
if (fullData.category.getTitle().isNotEmpty()) {
app_category.text = fullData.category.getTitle()
app_category.setOnClickListener {
binding.appCategory.text = fullData.category.getTitle()
binding.appCategory.setOnClickListener {
startActivity(Intent(this, CategoryActivity::class.java).apply {
putExtra(Constants.CATEGORY_KEY, fullData.category)
})
}
} else {
app_category.visibility = View.GONE
binding.appCategory.visibility = View.GONE
}
// Set the app description
if (fullData.description.isNotEmpty()) {
app_description.text = fullData.description
app_description_container.isEnabled = true
binding.appDescription.text = fullData.description
binding.appDescriptionContainer.isEnabled = true
} else {
app_description.text = getString(R.string.not_available_full)
app_description_container.isEnabled = false
binding.appDescription.text = getString(R.string.not_available_full)
binding.appDescriptionContainer.isEnabled = false
}
// Handle clicks on description
app_description_container.setOnClickListener {
binding.appDescriptionContainer.setOnClickListener {
val intent = Intent(this, ApplicationDescriptionActivity::class.java)
intent.putExtra(APPLICATION_DESCRIPTION_KEY, application.fullData!!.description)
startActivity(intent)
}
// Set the app rating
val builder = textColorChange(getText(R.string.not_available).toString())
if (basicData.ratings.rating != -1f) {
app_rating.text = basicData.ratings.rating.toString() + "/5"
binding.appRating.text = basicData.ratings.rating.toString() + "/5"
} else {
app_rating.text = builder
binding.appRating.text = textColorChange(getText(R.string.not_available).toString())
}
setRatingBorder(basicData.ratings.rating)
app_rating_container.setOnClickListener {
binding.appRatingContainer.setOnClickListener {
val alertDialog = AlertDialog.Builder(this).create()
alertDialog.setIcon(R.drawable.ic_app_rating)
......@@ -289,31 +295,29 @@ class ApplicationActivity :
//Set the app licence
if (fullData.licence.isNotEmpty()) {
app_licence.text = fullData.licence
binding.appLicence.text = fullData.licence
} else {
app_licence.text = getString(R.string.not_available)
binding.appLicence.text = getString(R.string.not_available)
}
if (fullData.getLastVersion() != null) {
// Set app size
if (fullData.getLastVersion()!!.fileSize.isNotEmpty()) {
app_size.text = fullData.getLastVersion()!!.fileSize
binding.appSize.text = fullData.getLastVersion()!!.fileSize
} else {
app_size.visibility = View.GONE
binding.appSize.visibility = View.GONE
}
// Set the app privacy rating
val builder = textColorChange(getText(R.string.not_available).toString())
if (fullData.getLastVersion()!!.privacyRating != null &&
fullData.getLastVersion()!!.privacyRating != -1) {
app_privacy_score.text = fullData.getLastVersion()!!.privacyRating.toString() + "/10"
fullData.getLastVersion()!!.privacyRating != -1) {
binding.appPrivacyScore.text = fullData.getLastVersion()!!.privacyRating.toString() + "/10"
setPrivacyRatingBorder(fullData.getLastVersion()!!.privacyRating!!)
} else {
app_privacy_score.text = builder
binding.appPrivacyScore.text = textColorChange(getText(R.string.not_available).toString())
setPrivacyRatingBorder(-1)
}
app_privacy_container.setOnClickListener {
binding.appPrivacyContainer.setOnClickListener {
val message = layoutInflater.inflate(R.layout.privacy_dialog_message, null) as
TextView
......@@ -338,40 +342,39 @@ class ApplicationActivity :
// Set app version
if (fullData.getLastVersion()!!.version.isNotEmpty()) {
app_version.text = fullData.getLastVersion()!!.version
binding.appVersion.text = fullData.getLastVersion()!!.version
} else {
app_version.text = getString(R.string.not_available)
binding.appVersion.text = getString(R.string.not_available)
}
// Set app package name.
if (fullData.packageName.isNotEmpty()) {
app_package_name.text = fullData.packageName
binding.appPackageName.text = fullData.packageName
} else {
app_package_name.text = getString(R.string.not_available)
binding.appPackageName.text = getString(R.string.not_available)
}
// Set app update timestamp
if (fullData.getLastVersion()!!.createdOn.isNotEmpty()) {
app_updated_on.text = getFormattedTimestamp(fullData.getLastVersion()!!.createdOn)
binding.appUpdatedOn.text = getFormattedTimestamp(fullData.getLastVersion()!!.createdOn)
} else {
app_updated_on.text = getString(R.string.not_available)
binding.appUpdatedOn.text = getString(R.string.not_available)
}
// Set app minimum required Android version
if (fullData.getLastVersion()!!.minAndroid.isNotEmpty()) {
app_min_android.text =