Commit fe80a4c9 authored by Aayush Gupta's avatar Aayush Gupta Committed by Romain Hunault
Browse files

Apps: Upstream, Cleanup and CI

parent d957da8d
image: "registry.gitlab.e.foundation:5000/e/apps/docker-android-apps-cicd:latest" image: "registry.gitlab.e.foundation:5000/e/apps/docker-android-apps-cicd:latest"
stages: stages:
- build - debug
- release
before_script: before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle - export GRADLE_USER_HOME=$(pwd)/.gradle
- chmod +x ./gradlew - chmod +x ./gradlew
build: # Debug build related jobs
stage: build buildDebug:
stage: debug
script: script:
- ./gradlew build - ./gradlew assembleDebug
artifacts: artifacts:
paths: paths:
- app/build/outputs/apk/ - app/build/outputs/apk/
# Default lint configuration for debug builds
# Manual as we don't want to run them generally for debug builds
.lintDebugDefault:
stage: debug
when: manual
allow_failure: true
lintDebug:
extends: .lintDebugDefault
script:
- ./gradlew lintDebug
artifacts:
paths:
- app/build/reports/ - app/build/reports/
ktlintDebug:
extends: .lintDebugDefault
script:
- ./gradlew app:ktlintCheck --info
artifacts:
paths:
- app/build/reports/ktlint/
# Release build related jobs
# Default configuration for release builds
# Only on "master" and "merge_request_event"
.releaseDefault:
stage: release
allow_failure: false
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: always
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
buildRelease:
extends: .releaseDefault
script:
- ./gradlew assembleRelease
artifacts:
paths:
- app/build/outputs/apk/
lintRelease:
extends: .releaseDefault
script:
- ./gradlew lintRelease
artifacts:
paths:
- app/build/reports/
ktlintRelease:
extends: .releaseDefault
script:
- ./gradlew app:ktlintCheck --info
artifacts:
paths:
- app/build/reports/ktlint/
\ No newline at end of file
...@@ -3,6 +3,7 @@ plugins { ...@@ -3,6 +3,7 @@ plugins {
id 'kotlin-android' id 'kotlin-android'
id 'kotlin-kapt' id 'kotlin-kapt'
id 'kotlin-parcelize' id 'kotlin-parcelize'
id "org.jlleitschuh.gradle.ktlint" version "10.1.0"
} }
android { android {
...@@ -30,26 +31,18 @@ android { ...@@ -30,26 +31,18 @@ android {
buildTypes { buildTypes {
debug { debug {
applicationIdSuffix ".debug" signingConfig signingConfigs.config
} }
release { release {
minifyEnabled false minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
platform {
signingConfig signingConfigs.config
}
} }
buildFeatures { buildFeatures {
viewBinding true viewBinding true
} }
lintOptions { lintOptions {
lintConfig file("lint.xml") lintConfig file("lint.xml")
disable 'MissingTranslation'
disable 'NullSafeMutableLiveData'
}
aaptOptions {
additionalParameters '-I', 'app/e-ui-sdk.jar'
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
...@@ -60,21 +53,22 @@ android { ...@@ -60,21 +53,22 @@ android {
} }
} }
ktlint {
disabledRules = ["no-wildcard-imports"]
}
dependencies { dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2' implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.0-rc01' implementation 'androidx.appcompat:appcompat:1.3.1'
implementation "com.google.android.material:material:1.3.0" implementation "com.google.android.material:material:1.4.0"
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
// eOS
compileOnly files("e-ui-sdk.jar")
// Preference // Preference
implementation "androidx.preference:preference-ktx:1.1.1" implementation "androidx.preference:preference-ktx:1.1.1"
...@@ -82,13 +76,13 @@ dependencies { ...@@ -82,13 +76,13 @@ dependencies {
implementation 'org.bouncycastle:bcpg-jdk15on:1.60' implementation 'org.bouncycastle:bcpg-jdk15on:1.60'
// GSON // GSON
implementation 'com.google.code.gson:gson:2.8.6' implementation 'com.google.code.gson:gson:2.8.7'
// PhotoView // PhotoView
implementation "com.github.chrisbanes:PhotoView:2.3.0" implementation "com.github.chrisbanes:PhotoView:2.3.0"
// RecyclerView // RecyclerView
implementation 'androidx.recyclerview:recyclerview:1.2.0' implementation 'androidx.recyclerview:recyclerview:1.2.1'
// WorkManager // WorkManager
implementation 'androidx.work:work-runtime-ktx:2.5.0' implementation 'androidx.work:work-runtime-ktx:2.5.0'
...@@ -110,7 +104,7 @@ dependencies { ...@@ -110,7 +104,7 @@ dependencies {
implementation "com.trello.rxlifecycle3:rxlifecycle-components-preference:$rxlifecycle_version" implementation "com.trello.rxlifecycle3:rxlifecycle-components-preference:$rxlifecycle_version"
// Jackson // Jackson
def jackson_version = "2.12.2" def jackson_version = "2.12.3"
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version" implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version" implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
......
...@@ -2,4 +2,6 @@ ...@@ -2,4 +2,6 @@
<issue id="InvalidPackage"> <issue id="InvalidPackage">
<ignore path="**/org.bouncycastle*.jar"/> <ignore path="**/org.bouncycastle*.jar"/>
</issue> </issue>
<issue id="NullSafeMutableLiveData" severity="warning"/>
<issue id="MissingTranslation" severity="warning"/>
</lint> </lint>
\ No newline at end of file
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
android:name=".pwa.PwaInstaller" android:name=".pwa.PwaInstaller"
android:theme="@style/FullScreenTheme" /> android:theme="@style/FullScreenTheme" />
<activity <activity
android:name=".XAPK.InstallSplitApksActivity" android:name=".xapk.InstallSplitApksActivity"
android:configChanges="screenSize|orientation|keyboardHidden" android:configChanges="screenSize|orientation|keyboardHidden"
android:launchMode="singleInstance" android:launchMode="singleInstance"
android:theme="@style/AppTheme1" android:theme="@style/AppTheme1"
......
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
package foundation.e.apps package foundation.e.apps
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.* import android.content.*
import android.content.pm.PackageManager import android.content.pm.PackageManager
...@@ -26,6 +24,7 @@ import android.content.res.ColorStateList ...@@ -26,6 +24,7 @@ import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.Looper
import android.view.MenuItem import android.view.MenuItem
import android.widget.Toast import android.widget.Toast
import androidx.annotation.ColorRes import androidx.annotation.ColorRes
...@@ -37,7 +36,6 @@ import androidx.preference.PreferenceManager ...@@ -37,7 +36,6 @@ import androidx.preference.PreferenceManager
import com.google.android.material.bottomnavigation.BottomNavigationItemView import com.google.android.material.bottomnavigation.BottomNavigationItemView
import com.google.android.material.bottomnavigation.BottomNavigationMenuView import com.google.android.material.bottomnavigation.BottomNavigationMenuView
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.bottomnavigation.LabelVisibilityMode
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import foundation.e.apps.applicationmanager.ApplicationManager import foundation.e.apps.applicationmanager.ApplicationManager
import foundation.e.apps.applicationmanager.ApplicationManagerServiceConnection import foundation.e.apps.applicationmanager.ApplicationManagerServiceConnection
...@@ -48,13 +46,14 @@ import foundation.e.apps.home.HomeFragment ...@@ -48,13 +46,14 @@ import foundation.e.apps.home.HomeFragment
import foundation.e.apps.search.SearchFragment import foundation.e.apps.search.SearchFragment
import foundation.e.apps.settings.SettingsFragment import foundation.e.apps.settings.SettingsFragment
import foundation.e.apps.updates.UpdatesFragment import foundation.e.apps.updates.UpdatesFragment
import foundation.e.apps.updates.UpdatesManager
import foundation.e.apps.utils.Common import foundation.e.apps.utils.Common
import foundation.e.apps.utils.Constants import foundation.e.apps.utils.Constants
import foundation.e.apps.utils.Constants.CURRENTLY_SELECTED_FRAGMENT_KEY import foundation.e.apps.utils.Constants.CURRENTLY_SELECTED_FRAGMENT_KEY
import kotlin.properties.Delegates import kotlin.properties.Delegates
class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemSelectedListener, class MainActivity :
AppCompatActivity(),
BottomNavigationView.OnNavigationItemSelectedListener,
ApplicationManagerServiceConnectionCallback { ApplicationManagerServiceConnectionCallback {
private lateinit var binding: ActivityMainBinding private lateinit var binding: ActivityMainBinding
...@@ -65,7 +64,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS ...@@ -65,7 +64,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
private val applicationManagerServiceConnection = private val applicationManagerServiceConnection =
ApplicationManagerServiceConnection(this) ApplicationManagerServiceConnection(this)
private val codeRequestPermissions = 9527 private val codeRequestPermissions = 9527
var doubleBackToExitPressedOnce = false; var doubleBackToExitPressedOnce = false
private var isReceiverRegistered = false private var isReceiverRegistered = false
private var accentColorOS by Delegates.notNull<Int>() private var accentColorOS by Delegates.notNull<Int>()
...@@ -77,7 +76,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS ...@@ -77,7 +76,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
private var instance: MainActivity? = null private var instance: MainActivity? = null
lateinit var mActivity: MainActivity lateinit var mActivity: MainActivity
var sharedPreferences : SharedPreferences?=null var sharedPreferences: SharedPreferences? = null
val sharedPrefFile = "kotlinsharedpreference" val sharedPrefFile = "kotlinsharedpreference"
/* /*
...@@ -89,8 +88,6 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS ...@@ -89,8 +88,6 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
} }
} }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
binding = ActivityMainBinding.inflate(layoutInflater) binding = ActivityMainBinding.inflate(layoutInflater)
...@@ -102,9 +99,8 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS ...@@ -102,9 +99,8 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
mActivity = this mActivity = this
disableCategoryIfOpenSource() disableCategoryIfOpenSource()
binding.bottomNavigationView.setOnNavigationItemSelectedListener {
binding.bottomNavigationView.setOnNavigationItemSelectedListener{ if (selectFragment(it.itemId, it)) {
if (selectFragment(it.itemId,it)) {
disableCategoryIfOpenSource() disableCategoryIfOpenSource()
currentFragmentId = it.itemId currentFragmentId = it.itemId
return@setOnNavigationItemSelectedListener true return@setOnNavigationItemSelectedListener true
...@@ -112,14 +108,14 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS ...@@ -112,14 +108,14 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
return@setOnNavigationItemSelectedListener false return@setOnNavigationItemSelectedListener false
} }
disableShiftingOfNabBarItems() disableShiftingOfNabBarItems()
Common.updateMicroGStatus(this) Common.updateMicroGStatus(this)
// Show the home fragment by default // Show the home fragment by default
currentFragmentId = if (savedInstanceState != null && currentFragmentId = if (savedInstanceState != null &&
savedInstanceState.containsKey(CURRENTLY_SELECTED_FRAGMENT_KEY)) { savedInstanceState.containsKey(CURRENTLY_SELECTED_FRAGMENT_KEY)
) {
savedInstanceState.getInt(CURRENTLY_SELECTED_FRAGMENT_KEY) savedInstanceState.getInt(CURRENTLY_SELECTED_FRAGMENT_KEY)
} else if (intent.hasExtra(Constants.UPDATES_NOTIFICATION_CLICK_EXTRA)) { } else if (intent.hasExtra(Constants.UPDATES_NOTIFICATION_CLICK_EXTRA)) {
R.id.menu_updates R.id.menu_updates
...@@ -139,32 +135,38 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS ...@@ -139,32 +135,38 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
} }
private fun openSearchFragment() { private fun openSearchFragment() {
if (intent.getBooleanExtra(Constants.OPEN_SEARCH,false)) { if (intent.getBooleanExtra(Constants.OPEN_SEARCH, false)) {
currentFragmentId = R.id.menu_search currentFragmentId = R.id.menu_search
val bundle = Bundle() val bundle = Bundle()
bundle.putString(Constants.MICROG_QUERY,"microg") bundle.putString(Constants.MICROG_QUERY, "microg")
searchFragment.arguments= bundle searchFragment.arguments = bundle
} }
} }
private fun bottom_navigation_view_color() { private fun bottom_navigation_view_color() {
val iconsColorStates = val iconsColorStates =
ColorStateList(arrayOf(intArrayOf(-android.R.attr.state_checked), ColorStateList(
intArrayOf(android.R.attr.state_checked)), intArrayOf( arrayOf(
intArrayOf(-android.R.attr.state_checked),
intArrayOf(android.R.attr.state_checked)
),
intArrayOf(
Color.parseColor("#C4CFD9"), Color.parseColor("#C4CFD9"),
accentColorOS accentColorOS
)) )
)
val textColorStates = ColorStateList(arrayOf(intArrayOf(-android.R.attr.state_checked), intArrayOf(android.R.attr.state_checked)), intArrayOf( val textColorStates = ColorStateList(
arrayOf(intArrayOf(-android.R.attr.state_checked), intArrayOf(android.R.attr.state_checked)),
intArrayOf(
Color.parseColor("#C4CFD9"), Color.parseColor("#C4CFD9"),
accentColorOS accentColorOS
)) )
)
binding.bottomNavigationView.setItemIconTintList(iconsColorStates) binding.bottomNavigationView.setItemIconTintList(iconsColorStates)
binding.bottomNavigationView.setItemTextColor(textColorStates) binding.bottomNavigationView.setItemTextColor(textColorStates)
} }
override fun onServiceBind(applicationManager: ApplicationManager) { override fun onServiceBind(applicationManager: ApplicationManager) {
...@@ -179,7 +181,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS ...@@ -179,7 +181,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
} }
override fun onNavigationItemSelected(item: MenuItem): Boolean { override fun onNavigationItemSelected(item: MenuItem): Boolean {
if (selectFragment(item.itemId,item)) { if (selectFragment(item.itemId, item)) {
currentFragmentId = item.itemId currentFragmentId = item.itemId
return true return true
} }
...@@ -205,7 +207,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS ...@@ -205,7 +207,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
val normalDrawable = item.icon val normalDrawable = item.icon
val wrapDrawable = DrawableCompat.wrap(normalDrawable) val wrapDrawable = DrawableCompat.wrap(normalDrawable)
DrawableCompat.setTint(wrapDrawable, ContextCompat.getColor(context, color))//context.resources.getColor(color)) DrawableCompat.setTint(wrapDrawable, ContextCompat.getColor(context, color)) // context.resources.getColor(color))
item.icon = wrapDrawable item.icon = wrapDrawable
} }
...@@ -226,7 +228,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS ...@@ -226,7 +228,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
return true return true
} }
R.id.menu_search -> { R.id.menu_search -> {
item?.setIcon(lineageos.platform.R.drawable.ic_search) item?.setIcon(R.drawable.ic_search)
showFragment(searchFragment) showFragment(searchFragment)
return true return true
} }
...@@ -236,7 +238,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS ...@@ -236,7 +238,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
return true return true
} }
R.id.menu_settings -> { R.id.menu_settings -> {
item?.setIcon(lineageos.platform.R.drawable.ic_settings) item?.setIcon(R.drawable.ic_settings)
showFragment(SettingsFragment()) showFragment(SettingsFragment())
return true return true
} }
...@@ -253,7 +255,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS ...@@ -253,7 +255,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
} }
val filter = IntentFilter(Intent.ACTION_LOCALE_CHANGED) val filter = IntentFilter(Intent.ACTION_LOCALE_CHANGED)
registerReceiver(mLangReceiver, filter) registerReceiver(mLangReceiver, filter)
isReceiverRegistered = true; isReceiverRegistered = true
} }
return mLangReceiver return mLangReceiver
} }
...@@ -263,7 +265,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS ...@@ -263,7 +265,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
supportFragmentManager supportFragmentManager
.beginTransaction() .beginTransaction()
.replace(R.id.frame_layout, fragment) .replace(R.id.frame_layout, fragment)
.commitAllowingStateLoss(); .commitAllowingStateLoss()
} }
@SuppressLint("RestrictedApi") @SuppressLint("RestrictedApi")
...@@ -282,23 +284,34 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS ...@@ -282,23 +284,34 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
for (i in 0 until menuView.childCount) { for (i in 0 until menuView.childCount) {
val itemView = menuView.getChildAt(i) as BottomNavigationItemView val itemView = menuView.getChildAt(i) as BottomNavigationItemView
itemView.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED); itemView.setChecked(itemView.itemData.isChecked) itemView.setLabelVisibilityMode(BottomNavigationView.LABEL_VISIBILITY_LABELED)
itemView.itemData?.isChecked?.let {
itemView.setChecked(
it
)
}
} }
} }
private fun disableCategoryIfOpenSource(){ private fun disableCategoryIfOpenSource() {
if(showApplicationTypePreference()=="open") { if (showApplicationTypePreference() == "open") {
binding.bottomNavigationView.menu.removeItem(R.id.menu_categories) binding.bottomNavigationView.menu.removeItem(R.id.menu_categories)
} }
} }
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, override fun onRequestPermissionsResult(
grantResults: IntArray) { requestCode: Int,
permissions: Array<out String>,
grantResults: IntArray
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults) super.onRequestPermissionsResult(requestCode, permissions, grantResults)
if (requestCode == Constants.STORAGE_PERMISSION_REQUEST_CODE && if (requestCode == Constants.STORAGE_PERMISSION_REQUEST_CODE &&
grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_DENIED) { grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_DENIED
Snackbar.make(binding.container, R.string.error_storage_permission_denied, ) {
Snackbar.LENGTH_LONG).show() Snackbar.make(
binding.container, R.string.error_storage_permission_denied,
Snackbar.LENGTH_LONG
).show()
} }
} }
...@@ -325,13 +338,16 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS ...@@ -325,13 +338,16 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
return return
} }
this.doubleBackToExitPressedOnce = true; this.doubleBackToExitPressedOnce = true
Toast.makeText(this, R.string.exit, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.exit, Toast.LENGTH_SHORT).show()
Handler().postDelayed(Runnable() { Handler(Looper.getMainLooper()).postDelayed(
Runnable() {
run { run {
doubleBackToExitPressedOnce = false; doubleBackToExitPressedOnce = false
} }
}, 2000) },
2000
)