0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-01 00:32:39 +00:00
This commit is contained in:
X1nto 2020-08-04 19:10:05 +04:00
parent 14a964c9d9
commit cbc31a64ad
8 changed files with 55 additions and 15 deletions

View file

@ -27,8 +27,8 @@ jobs:
- name: Build Debug APK with Gradle - name: Build Debug APK with Gradle
run: ./gradlew assembleDebug run: ./gradlew assembleDebug
- name: Upload to GitHub - name: Upload Debug
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: 'Vanced-Manager' name: 'Manager'
path: app/build/outputs/apk/debug/app-debug.apk path: app/build/outputs/apk/debug/app-debug.apk

View file

@ -130,7 +130,7 @@ class VancedDownloadService: Service() {
*/ */
private fun prepareInstall(variant: String) { private fun prepareInstall(variant: String) {
LocalBroadcastManager.getInstance(this).sendBroadcast(Intent(HomeFragment.VANCED_DOWNLOADED)) //LocalBroadcastManager.getInstance(this).sendBroadcast(Intent(HomeFragment.VANCED_DOWNLOADED))
if (variant == "root") if (variant == "root")
startService(Intent(this, RootSplitInstallerService::class.java)) startService(Intent(this, RootSplitInstallerService::class.java))
else else

View file

@ -1,7 +1,6 @@
package com.vanced.manager.core.installer package com.vanced.manager.core.installer
import android.app.Service import android.app.Service
import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.AsyncTask import android.os.AsyncTask
import android.os.Build import android.os.Build
@ -13,7 +12,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager
import com.topjohnwu.superuser.Shell import com.topjohnwu.superuser.Shell
import com.vanced.manager.R import com.vanced.manager.R
import com.vanced.manager.ui.MainActivity import com.vanced.manager.ui.MainActivity
import com.vanced.manager.utils.AppUtils import com.vanced.manager.ui.fragments.HomeFragment
import com.vanced.manager.utils.FileInfo import com.vanced.manager.utils.FileInfo
import com.vanced.manager.utils.NotificationHelper.createBasicNotif import com.vanced.manager.utils.NotificationHelper.createBasicNotif
import java.io.File import java.io.File
@ -43,6 +42,7 @@ class RootSplitInstallerService: Service() {
@WorkerThread @WorkerThread
private fun installSplitApkFiles(apkFiles: ArrayList<FileInfo>) { private fun installSplitApkFiles(apkFiles: ArrayList<FileInfo>) {
val broadcast = LocalBroadcastManager.getInstance(this)
var sessionId: Int? var sessionId: Int?
val notifId = 666 val notifId = 666
Log.d("AppLog", "installing split apk files:$apkFiles") Log.d("AppLog", "installing split apk files:$apkFiles")
@ -77,16 +77,14 @@ class RootSplitInstallerService: Service() {
} }
Log.d("AppLog", "committing...") Log.d("AppLog", "committing...")
val installResult = Shell.su("pm install-commit $sessionId").exec() val installResult = Shell.su("pm install-commit $sessionId").exec()
Log.d("AppLog", "succeeded installing?${installResult.isSuccess}")
getSharedPreferences("installPrefs", Context.MODE_PRIVATE).edit().putBoolean("isInstalling", false).apply()
if (installResult.isSuccess) { if (installResult.isSuccess) {
AppUtils.sendRefreshHome(this) broadcast.sendBroadcast(Intent(HomeFragment.REFRESH_HOME))
broadcast.sendBroadcast(Intent(MainActivity.INSTALL_COMPLETED).putExtra("pkg", "vanced"))
createBasicNotif(getString(R.string.successfully_installed, "Vanced"), notifId, this) createBasicNotif(getString(R.string.successfully_installed, "Vanced"), notifId, this)
} else { } else {
val mIntent = Intent(MainActivity.INSTALL_FAILED) val mIntent = Intent(MainActivity.INSTALL_FAILED)
mIntent.action = MainActivity.INSTALL_FAILED
mIntent.putExtra("errorMsg", getString(R.string.installation_signature)) mIntent.putExtra("errorMsg", getString(R.string.installation_signature))
LocalBroadcastManager.getInstance(this).sendBroadcast(mIntent) broadcast.sendBroadcast(mIntent)
createBasicNotif(getString(R.string.installation_signature), notifId, this) createBasicNotif(getString(R.string.installation_signature), notifId, this)
} }
} }

View file

@ -9,6 +9,7 @@ import android.util.Log
import androidx.localbroadcastmanager.content.LocalBroadcastManager import androidx.localbroadcastmanager.content.LocalBroadcastManager
import com.vanced.manager.R import com.vanced.manager.R
import com.vanced.manager.ui.MainActivity import com.vanced.manager.ui.MainActivity
import com.vanced.manager.ui.fragments.HomeFragment
import com.vanced.manager.utils.AppUtils.getErrorMessage import com.vanced.manager.utils.AppUtils.getErrorMessage
import com.vanced.manager.utils.AppUtils.sendRefreshHome import com.vanced.manager.utils.AppUtils.sendRefreshHome
import com.vanced.manager.utils.NotificationHelper.createBasicNotif import com.vanced.manager.utils.NotificationHelper.createBasicNotif
@ -30,8 +31,7 @@ class SplitInstallerService: Service() {
} }
PackageInstaller.STATUS_SUCCESS -> { PackageInstaller.STATUS_SUCCESS -> {
Log.d(TAG, "Installation succeed") Log.d(TAG, "Installation succeed")
getSharedPreferences("installPrefs", Context.MODE_PRIVATE).edit().putBoolean("isInstalling", false).apply() LocalBroadcastManager.getInstance(this).sendBroadcast(Intent(HomeFragment.REFRESH_HOME))
sendRefreshHome(this)
createBasicNotif( createBasicNotif(
getString(R.string.successfully_installed, "Vanced"), getString(R.string.successfully_installed, "Vanced"),
notifId, notifId,
@ -53,7 +53,6 @@ class SplitInstallerService: Service() {
private fun sendFailure(status: Int) { private fun sendFailure(status: Int) {
val mIntent = Intent(MainActivity.INSTALL_FAILED) val mIntent = Intent(MainActivity.INSTALL_FAILED)
mIntent.action = MainActivity.INSTALL_FAILED
mIntent.putExtra("errorMsg", getErrorMessage(status, this)) mIntent.putExtra("errorMsg", getErrorMessage(status, this))
LocalBroadcastManager.getInstance(this).sendBroadcast(mIntent) LocalBroadcastManager.getInstance(this).sendBroadcast(mIntent)
} }

View file

@ -202,8 +202,8 @@ class HomeFragment : Fragment(), View.OnClickListener {
private fun registerReceivers() { private fun registerReceivers() {
val intentFilter = IntentFilter() val intentFilter = IntentFilter()
intentFilter.addAction(VANCED_DOWNLOADED) //intentFilter.addAction(VANCED_DOWNLOADED)
intentFilter.addAction(MICROG_DOWNLOADED) //intentFilter.addAction(MICROG_DOWNLOADED)
intentFilter.addAction(REFRESH_HOME) intentFilter.addAction(REFRESH_HOME)
localBroadcastManager.registerReceiver(broadcastReceiver, intentFilter) localBroadcastManager.registerReceiver(broadcastReceiver, intentFilter)
} }

View file

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LightTheme.Blue" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">#1490D7</item>
<item name="colorPrimaryVariant">#2C7EB9</item>
<item name="colorSecondary">#3E78AF</item>
<item name="colorSecondaryVariant">#803E78AF</item>
<item name="colorSurface">#ffffff</item>
<item name="colorSurfaceVariant">#F3F3F3</item>
<item name="colorSurfaceSurfaceVariant">?colorSurface</item>
<item name="colorOnPrimary">#F9F9F9</item>
<item name="colorOnPrimaryVariant">#e8e8e8</item>
<item name="colorOnSecondary">#F9F9F9</item>
<item name="colorOnBackground">?colorOnSurface</item>
<item name="colorError">#CC0047</item>
<item name="colorOnError">#F9F9F9</item>
<item name="colorOnSurface">#444444</item>
<item name="colorOnSurfaceVariant">#C3131313</item>
<item name="colorDisabled">@color/Gray</item>
<item name="colorDisabledVariant">#000000</item>
<item name="iconColor">?colorPrimaryVariant</item>
<item name="toolbarIconColor">#111111</item>
<item name="DialogBG">#ffffff</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowBackground">?colorSurface</item>
<item name="android:statusBarColor">#ffffff</item>
<item name="materialAlertDialogTheme">@style/DialogStyle</item>
<item name="snackbarStyle">@style/SnackBar</item>
</style>
</resources>

View file

@ -142,4 +142,9 @@
<item name="tint">@color/Red</item> <item name="tint">@color/Red</item>
</style> </style>
<style name="SnackBar" parent="Widget.MaterialComponents.Snackbar">
<item name="android:backgroundTint">?colorSurface</item>
<item name="android:textColor">?colorOnSurfaceVariant</item>
</style>
</resources> </resources>

View file

@ -29,6 +29,7 @@
<item name="android:windowBackground">?colorSurface</item> <item name="android:windowBackground">?colorSurface</item>
<item name="android:statusBarColor">#787777</item> <item name="android:statusBarColor">#787777</item>
<item name="materialAlertDialogTheme">@style/DialogStyle</item> <item name="materialAlertDialogTheme">@style/DialogStyle</item>
<item name="snackbarStyle">@style/SnackBar</item>
</style> </style>
@ -97,6 +98,7 @@
<item name="android:statusBarColor">?colorSurface</item> <item name="android:statusBarColor">?colorSurface</item>
<item name="android:navigationBarColor">#000000</item> <item name="android:navigationBarColor">#000000</item>
<item name="materialAlertDialogTheme">@style/DialogStyle</item> <item name="materialAlertDialogTheme">@style/DialogStyle</item>
<item name="snackbarStyle">@style/SnackBar</item>
</style> </style>