Commit 79cdb445 authored by Dayona Joseph's avatar Dayona Joseph Committed by Arnau Vàzquez
Browse files

Remove installing view for xapk

parent 19ecfd8b
......@@ -23,7 +23,8 @@
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:largeHeap="true"
android:launchMode="singleTask"
android:launchMode="singleInstance"
android:alwaysRetainTaskState="true"
android:theme="@style/AppTheme">
<!-- <activity android:name=".application.PwaInstaller"/>-->
<activity android:name=".settings.AppRequestActivity" />
......@@ -63,9 +64,9 @@
<activity
android:name=".XAPK.InstallSplitApksActivity"
android:configChanges="screenSize|orientation|keyboardHidden"
android:label="XAPK Installer"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize" />
android:launchMode="singleInstance"
android:windowSoftInputMode="adjustResize"
android:theme="@style/AppTheme1"/>
</application>
</manifest>
\ No newline at end of file
</manifest>
......@@ -11,11 +11,9 @@ abstract class BaseActivity : RxAppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
init()
nextStep()
finish()
}
protected open fun init() {}
protected open fun nextStep() {}
}
package foundation.e.apps.XAPK
import org.greenrobot.eventbus.EventBus
object EventManager {
fun register(subscriber: Any) {
EventBus.getDefault().register(subscriber)
}
fun unregister(subscriber: Any) {
EventBus.getDefault().unregister(subscriber)
}
}
\ No newline at end of file
package foundation.e.apps.XAPK
abstract class IBaseActivity : BaseActivity(){
override fun init() {
super.init()
setContentView(getLayout())
// EventManager.register(this)
}
override fun onDestroy() {
super.onDestroy()
// EventManager.unregister(this)
}
protected abstract fun getLayout(): Int
}
......@@ -13,8 +13,8 @@ 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.BuildConfig
import foundation.e.apps.R
import java.io.File
import java.io.FileInputStream
......@@ -22,7 +22,7 @@ import java.io.IOException
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
class InstallSplitApksActivity : IBaseActivity() {
class InstallSplitApksActivity : BaseActivity() {
private var apksBean: ApksBean?=null
companion object{
......@@ -37,10 +37,6 @@ class InstallSplitApksActivity : IBaseActivity() {
}
}
override fun getLayout(): Int {
return R.layout.activity_install_split_apks
}
override fun nextStep() {
super.nextStep()
apksBean = intent.getParcelableExtra(KEY_PARAM)
......@@ -51,25 +47,6 @@ class InstallSplitApksActivity : IBaseActivity() {
finish()
return
}
val iconRiv: RoundedImageView = findViewById(R.id.icon_riv)
val titleTv: TextView = findViewById(R.id.title_tv)
titleTv.text = apksBean!!.label
val apkAssetType = apksBean!!.apkAssetType
val iconUrl = apksBean!!.iconPath
if (!TextUtils.isEmpty(iconUrl) && apkAssetType != null) {
iconRiv.visibility = View.VISIBLE
// if (apkAssetType == ApkAssetType.XAPK) {
// ImageLoader.Builder(mContext, XApkIconUrl(iconUrl))
// .setRequestOptions(ImageLoader.defaultRequestOptions(R.color.placeholder_color))
// .build(iconRiv)
// } else if (apkAssetType == ApkAssetType.Apks) {
// ImageLoader.Builder(mContext, ApkIconUrl(iconUrl, -1))
// .setRequestOptions(ImageLoader.defaultRequestOptions(R.color.placeholder_color))
// .build(iconRiv)
// }
} else {
iconRiv.visibility = View.GONE
}
Handler(Looper.getMainLooper()).postDelayed({ this.install() }, 500)
}
......@@ -93,6 +70,7 @@ class InstallSplitApksActivity : IBaseActivity() {
val statusReceiver = pendingIntent.intentSender
// Commit the session (this will start the installation workflow).
session!!.commit(statusReceiver)
finish()
} catch (e: IOException) {
e.printStackTrace()
finish()
......@@ -165,19 +143,17 @@ class InstallSplitApksActivity : IBaseActivity() {
FsUtils.deleteFileOrDir(it)
}
}
findViewById<View>(R.id.installing_status_view).visibility = View.GONE
findViewById<View>(R.id.installed_status_view).visibility = View.VISIBLE
}
}
}
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
return if (keyCode == KeyEvent.KEYCODE_BACK) {
true
} else {
super.onKeyDown(keyCode, event)
}
}
// override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
// return if (keyCode == KeyEvent.KEYCODE_BACK) {
// true
// } else {
// super.onKeyDown(keyCode, event)
// }
// }
}
......
......@@ -2,12 +2,19 @@ package foundation.e.apps.XAPK
import android.content.Context
import android.os.Build
import android.os.Handler
import androidx.annotation.RequiresApi
import foundation.e.apps.application.model.InstallerInterface
object LaunchUtils {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
fun startInstallSplitApksActivity(mActivity: Context, apksBean: ApksBean) {
fun startInstallSplitApksActivity(mActivity: Context, apksBean: ApksBean, callback: InstallerInterface) {
mActivity.startActivity(InstallSplitApksActivity.newInstanceIntent(mActivity, apksBean))
val handler = Handler()
handler.postDelayed({
callback.onInstallationComplete(mActivity)
}, 10000)
}
}
......@@ -5,14 +5,15 @@ import android.content.Context
import android.os.Build
import androidx.annotation.MainThread
import foundation.e.apps.R
import foundation.e.apps.application.model.InstallerInterface
import java.io.File
object ViewUtils {
@MainThread
fun installXApk(mContext: Context, xApkInfo: XApkInfo) {
XApkInstallUtils.installXApk(File(xApkInfo.path), object : XApkInstallUtils.XApkInstallProgressCallback {
fun installXApk(mContext: Context, xApkInfo: XApkInfo, callback: InstallerInterface) {
XApkInstallUtils.installXApk(File(xApkInfo.path),callback, object : XApkInstallUtils.XApkInstallProgressCallback {
private var progressDialog: ProgressDialog? = null
override fun onStart() {
// progress dialog if needed
......@@ -45,7 +46,7 @@ object ViewUtils {
IntentUtils.installedApk(mContext, apkFile.absolutePath)
}
override fun onCompedApks(apksBean: ApksBean) {
override fun onCompedApks(apksBean: ApksBean, callback: InstallerInterface) {
progressDialog?.apply {
if (this.isShowing) {
this.dismiss()
......@@ -54,7 +55,7 @@ object ViewUtils {
when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP -> LaunchUtils.startInstallSplitApksActivity(
mContext,
apksBean
apksBean,callback
)
apksBean.splitApkPaths?.size == 1 -> IntentUtils.installedApk(mContext, apksBean.splitApkPaths!![0])
else -> onError(XApkInstallUtils.InstallError.LowerSdkError)
......
package foundation.e.apps.XAPK
import foundation.e.apps.MainActivity.Companion.mActivity
import foundation.e.apps.application.model.InstallerInterface
import java.io.File
class XAPKFile(x: File) {
class XAPKFile(x: File, callback: InstallerInterface) {
init{
val fileName =getSingleXApkAssetInfo(x)
fileName?.xApkInfo?.let { it1 -> ViewUtils.installXApk(mActivity, it1) }
fileName?.xApkInfo?.let { it1 -> ViewUtils.installXApk(mActivity, it1,callback) }
}
......
......@@ -5,6 +5,7 @@ import android.os.Handler
import android.os.Looper
import androidx.annotation.MainThread
import androidx.annotation.WorkerThread
import foundation.e.apps.application.model.InstallerInterface
import java.io.File
import java.io.InputStream
import java.io.InputStreamReader
......@@ -22,7 +23,7 @@ object XApkInstallUtils {
}
@MainThread
fun installXApk(xApkFile: File, xApkInstallProgressCallback: XApkInstallProgressCallback?) {
fun installXApk(xApkFile: File, callback: InstallerInterface, xApkInstallProgressCallback: XApkInstallProgressCallback?) {
Thread(Runnable {
var zipFile: ZipFile? = null
try {
......@@ -48,7 +49,7 @@ object XApkInstallUtils {
installXApkObb(zipFile!!, this, xApkInstallProgressCallback)
}
if (this.useSplitApks()) {
installSplitApks(xApkFile, zipFile!!, this, xApkInstallProgressCallback)
installSplitApks(xApkFile, zipFile!!,callback, this, xApkInstallProgressCallback)
}
// else {
// installApk(zipFile!!, this, xApkInstallProgressCallback)
......@@ -81,7 +82,7 @@ object XApkInstallUtils {
fun onCompedApk(apkFile: File)
@MainThread
fun onCompedApks(apksBean: ApksBean)
fun onCompedApks(apksBean: ApksBean, callback: InstallerInterface)
@MainThread
fun onError(installError: InstallError)
......@@ -153,7 +154,8 @@ object XApkInstallUtils {
}
}
}
private fun installSplitApks(xApkFile: File, zipFile: ZipFile, xApkManifest: XApkManifest,
private fun installSplitApks(xApkFile: File, zipFile: ZipFile, callback: InstallerInterface,
xApkManifest: XApkManifest,
xApkInstallProgressCallback: XApkInstallProgressCallback?){
val fileList= arrayListOf<String>()
if (xApkManifest.useSplitApks()){
......@@ -192,7 +194,7 @@ object XApkInstallUtils {
this.outputFileDir = AppFolder.getXApkInstallTempFolder(packageName).absolutePath
this.iconPath = xApkFile.absolutePath
this.apkAssetType = ApkAssetType.XAPK
})
},callback)
}
} else {
handler.post {
......
......@@ -204,9 +204,8 @@ class Application(val packageName: String, private val applicationManager: Appli
AppDownloadedRequest(basicData!!.id).request()
}, {})
if(info.isXapk(fullData!!,basicData)){
XAPKFile(info.getxApkFile(context,basicData!!))
downloader = null
onInstallationComplete(context)
isInstalling=true
XAPKFile(info.getxApkFile(context,basicData!!),this)
}
else {
install(context)
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="foundation.e.apps.XAPK.InstallSplitApksActivity">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:contentInsetLeft="16dp"
app:contentInsetStart="16dp"
app:layout_scrollFlags="enterAlways|snap"
app:theme="@style/CustomAppBarTheme">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/icon_riv"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:scaleType="centerCrop"
tools:src="@mipmap/ic_launcher" />
<TextView
android:id="@+id/title_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffffff"
android:textSize="18sp"
tools:text="XAPK Installer" />
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
<LinearLayout
android:id="@+id/constraintLayout"
android:layout_width="100dp"
android:padding="20dp"
android:layout_gravity="center"
android:layout_height="match_parent">
app:layout_behavior="@string/behavior_appbar_scrolling_view">
<LinearLayout
android:id="@+id/installing_status_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ProgressBar
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="installing" />
</LinearLayout>
<LinearLayout
android:id="@+id/installed_status_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:layout_width="64dp"
android:layout_height="64dp"/>
<!--app:srcCompat="@drawable/install_app_done_svg"-->
<!--/>-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="installing" />
</LinearLayout>
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
......@@ -33,7 +33,10 @@
<item name="colorControlActivated">@color/colorInstall</item>
</style>
<style name="AppTheme" parent="BaseTheme" />
<style name="AppTheme1" parent="android:Theme">
<item name="android:windowDisablePreview">true</item>
</style>
<style name="AppTheme" parent="BaseTheme"/>
<style name="SearchSuggestionTheme" parent="Widget.AppCompat.Light.AutoCompleteTextView">
<item name="android:popupBackground">#FAFAFA</item>
......
Supports Markdown
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