Commit 5c74f501 authored by Aayush Gupta's avatar Aayush Gupta
Browse files

Merge branch 'aayush_test' into 'master'

Multiple improvements to Apps

See merge request e/apps/apps!60
parents d80fd6b4 8c1a6964
Pipeline #110832 passed with stage
in 4 minutes and 9 seconds
......@@ -7,11 +7,6 @@ before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle
- chmod +x ./gradlew
cache:
key: ${CI_PROJECT_ID}
paths:
- .gradle/
build:
stage: build
script:
......@@ -19,4 +14,4 @@ build:
artifacts:
paths:
- app/build/outputs/apk/
\ No newline at end of file
- app/build/reports/
\ No newline at end of file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
}
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
compileSdkVersion 29
buildToolsVersion '29.0.2'
defaultConfig {
applicationId "foundation.e.apps"
minSdkVersion 21
targetSdkVersion 27
minSdkVersion 25
targetSdkVersion 29
versionCode 10
versionName "1.1.6"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions.cruncherEnabled = false
vectorDrawables.useSupportLibrary = true
}
buildTypes {
debug {
applicationIdSuffix ".debug"
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
lintOptions {
lintConfig file("lint.xml")
disable 'MissingTranslation'
}
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
androidExtensions {
experimental = true
}
aaptOptions{
aaptOptions {
additionalParameters '-I', 'app/e-ui-sdk.jar'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
def lifecycle_version = "1.1.1"
implementation 'androidx.work:work-runtime:2.3.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.3.0-rc01'
implementation "com.google.android.material:material:1.3.0"
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
// implementation 'com.android.support:design:27.1.1'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
testImplementation 'junit:junit:4.12'
// eOS
compileOnly files("e-ui-sdk.jar")
// 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'
implementation "androidx.vectordrawable:vectordrawable:1.0.0"
implementation "androidx.vectordrawable:vectordrawable-animated:1.0.0"
implementation 'com.google.android.material:material:1.1.0-alpha05'
// GSON
implementation 'com.google.code.gson:gson:2.8.6'
def nav_version = "1.0.0-alpha02"
implementation 'androidx.navigation:navigation-fragment-ktx:2.0.0-rc02'
// use -ktx for Kotlin
implementation 'androidx.navigation:navigation-ui-ktx:2.0.0-rc02'
// EventBus
implementation 'org.greenrobot:eventbus:3.2.0'
implementation "androidx.preference:preference-ktx:1.1.0"
// Volley
implementation "com.android.volley:volley:1.2.0"
implementation 'androidx.lifecycle:lifecycle-viewmodel:2.0.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'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.google.android.material:material:1.0.0'
// WorkManager
implementation 'androidx.work:work-runtime: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'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.trello.rxlifecycle3:rxlifecycle-android:3.1.0'
implementation 'com.trello.rxlifecycle3:rxlifecycle-components:3.1.0'
implementation 'com.trello.rxlifecycle3:rxlifecycle-components-preference:3.1.0'
implementation 'com.makeramen:roundedimageview:2.3.0'
// Vectordrawable
def vector_version = "1.1.0"
implementation "androidx.vectordrawable:vectordrawable:$vector_version"
implementation "androidx.vectordrawable:vectordrawable-animated:$vector_version"
// Jackson
implementation "com.fasterxml.jackson.core:jackson-core:2.11.1"
implementation "com.fasterxml.jackson.core:jackson-annotations:2.11.1"
implementation "com.fasterxml.jackson.core:jackson-databind:2.11.1"
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.11.1"
// Navigation component
def nav_version = "2.3.5"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
implementation 'com.android.volley:volley:1.1.1'
// RxLifecycle
def rxlifecycle_version = "3.1.0"
implementation "com.trello.rxlifecycle3:rxlifecycle-android:$rxlifecycle_version"
implementation "com.trello.rxlifecycle3:rxlifecycle-components:$rxlifecycle_version"
implementation "com.trello.rxlifecycle3:rxlifecycle-components-preference:$rxlifecycle_version"
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
compileOnly files("e-ui-sdk.jar")
// Jackson
def jackson_version = "2.12.2"
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
implementation "com.fasterxml.jackson.module:jackson-module-kotlin:$jackson_version"
}
......@@ -21,7 +21,7 @@
<uses-permission android:name="foundation.e.apps.micro.status.READ_WRITE" />
<application
android:allowBackup="true"
android:allowBackup="false"
android:alwaysRetainTaskState="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
......
/*
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/>.
* Copyright (C) 2019-2021 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
//import androidx.fragment.app.ListFragment
import android.annotation.SuppressLint
......@@ -28,18 +27,14 @@ import android.database.Cursor
import android.graphics.Color
import android.os.Bundle
import android.os.Handler
import android.preference.PreferenceManager
import android.util.Log
import android.util.TypedValue
import android.view.MenuItem
import android.widget.Toast
import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ContextThemeWrapper
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import androidx.fragment.app.Fragment
import androidx.preference.PreferenceManager
import com.google.android.material.bottomnavigation.BottomNavigationItemView
import com.google.android.material.bottomnavigation.BottomNavigationMenuView
import com.google.android.material.bottomnavigation.BottomNavigationView
......@@ -74,18 +69,30 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
private var isReceiverRegistered = false
var accentColorOS = 0
init {
instance = this
}
companion object {
private var instance: MainActivity? = null
lateinit var mActivity: MainActivity
var sharedPreferences : SharedPreferences?=null
val sharedPrefFile = "kotlinsharedpreference"
/*
* Provides the application context via MainActivity
* @return applicationContext
*/
fun applicationContext(): Context {
return instance!!.applicationContext
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
//ThemeColors(this);
setContentView(R.layout.activity_main)
mActivity = this
disableCategoryIfOpenSource()
......@@ -311,6 +318,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>,
grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
if (requestCode == Constants.STORAGE_PERMISSION_REQUEST_CODE &&
grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_DENIED) {
Snackbar.make(container, R.string.error_storage_permission_denied,
......@@ -320,7 +328,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState?.putInt(CURRENTLY_SELECTED_FRAGMENT_KEY, currentFragmentId)
outState.putInt(CURRENTLY_SELECTED_FRAGMENT_KEY, currentFragmentId)
}
override fun onDestroy() {
......@@ -357,7 +365,7 @@ class MainActivity : AppCompatActivity(), BottomNavigationView.OnNavigationItemS
* */
private fun getAccentColor() {
accentColorOS=this.resources.getColor(R.color.colorAccent);
accentColorOS = this.getColor(R.color.colorAccent);
......
package foundation.e.apps;
/*
* Copyright (C) 2019-2021 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/>.
*/
import java.util.HashMap;
package foundation.e.apps;
import android.content.ContentProvider;
import android.content.ContentUris;
......@@ -14,6 +29,8 @@ import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import java.util.HashMap;
public class MicroGProvider extends ContentProvider {
public static final String PROVIDER_NAME = "foundation.e.apps.micro.status";
......
/*
* Copyright (C) 2019-2021 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.XAPK
data class ApkAssetBean(
......
/*
* Copyright (C) 2019-2021 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.XAPK
enum class ApkAssetType(val suffix: String) {
......
/*
* Copyright (C) 2019-2021 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.XAPK
import android.annotation.SuppressLint
......
/*
* Copyright (C) 2019-2021 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.XAPK
import android.os.Environment
import foundation.e.apps.BuildConfig
import foundation.e.apps.MainActivity
import java.io.File
object AppFolder {
......@@ -34,7 +52,8 @@ object AppFolder {
private val appFolder: File?
get() {
return if (FsUtils.isSdUsable) {
val appFolder = File(Environment.getExternalStorageDirectory(), APP_FOLDER_NAME)
val appContext = MainActivity.applicationContext()
val appFolder = File(appContext.getExternalFilesDir(null), APP_FOLDER_NAME)
FsUtils.createOnNotFound(appFolder)
} else {
null
......
/*
* Copyright (C) 2019-2021 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.XAPK
import android.os.Bundle
......
/*
* Copyright (C) 2019-2021 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.XAPK
import androidx.annotation.WorkerThread
......
/*
* Copyright (C) 2019-2021 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.XAPK
object FormatUtils {
......
/*
* Copyright (C) 2019-2021 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.XAPK
import android.os.Environment
import android.text.TextUtils
import foundation.e.apps.MainActivity
import java.io.File
object FsUtils {
......@@ -11,7 +29,8 @@ object FsUtils {
fun getStorageDir(): File? {
return if (isSdUsable) {
Environment.getExternalStorageDirectory()
val appContext = MainActivity.applicationContext()
appContext.getExternalFilesDir(null)
} else {
null
}
......
/*
* Copyright (C) 2019-2021 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.XAPK
import android.app.PendingIntent
......@@ -8,14 +25,8 @@ import android.content.pm.PackageInstaller
import android.os.Build
import android.os.Handler
import android.os.Looper
import android.text.TextUtils
import android.view.KeyEvent
import android.view.View
import android.widget.TextView
import androidx.annotation.RequiresApi
import com.makeramen.roundedimageview.BuildConfig
import com.makeramen.roundedimageview.RoundedImageView
import foundation.e.apps.R
import java.io.File
import java.io.FileInputStream
import java.io.IOException
......@@ -43,7 +54,6 @@ class InstallSplitApksActivity : BaseActivity() {
if (apksBean == null
|| apksBean!!.splitApkPaths.isNullOrEmpty()
|| apksBean!!.packageName.isEmpty()) {
// SimpleToast.defaultShow(mContext, R.string.install_failed)
finish()
return
}
......@@ -69,7 +79,7 @@ class InstallSplitApksActivity : BaseActivity() {
val pendingIntent = PendingIntent.getActivity(mActivity, 0, intent, 0)
val statusReceiver = pendingIntent.intentSender
// Commit the session (this will start the installation workflow).
session!!.commit(statusReceiver)
session.commit(statusReceiver)
finish()
} catch (e: IOException) {
e.printStackTrace()
......@@ -106,7 +116,6 @@ class InstallSplitApksActivity : BaseActivity() {
val extras = intent.extras
if (PACKAGE_INSTALLED_ACTION == intent.action) {
val status = extras!!.getInt(PackageInstaller.EXTRA_STATUS)
val message = extras.getString(PackageInstaller.EXTRA_STATUS_MESSAGE)
when (status) {
PackageInstaller.STATUS_PENDING_USER_ACTION -> {
// This test app isn't privileged, so the user has to confirm the install.
......@@ -114,7 +123,6 @@ class InstallSplitApksActivity : BaseActivity() {
startActivity(confirmIntent)
}
PackageInstaller.STATUS_SUCCESS -> {
// SimpleToast.defaultShow(this, R.string.install_success)
finish()
}