mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-21 18:55:12 +00:00
added a launch button for apps
This commit is contained in:
parent
b794afa294
commit
e7c10d01e8
4 changed files with 49 additions and 1 deletions
|
@ -45,9 +45,16 @@ class AppListAdapter(
|
|||
appUninstall.setOnClickListener {
|
||||
dataModel?.appPkg?.let { it1 -> viewModel.uninstallPackage(it1) }
|
||||
}
|
||||
appUninstall.isVisible = dataModel?.isAppInstalled?.value == true
|
||||
appLaunch.setOnClickListener {
|
||||
viewModel.launchApp(apps[position], isRoot)
|
||||
}
|
||||
with(dataModel?.isAppInstalled?.value) {
|
||||
appUninstall.isVisible = this == true
|
||||
appLaunch.isVisible = this == true
|
||||
}
|
||||
dataModel?.isAppInstalled?.observe(lifecycleOwner) {
|
||||
appUninstall.isVisible = it
|
||||
appLaunch.isVisible = it
|
||||
}
|
||||
appRemoteVersion.text = dataModel?.versionName?.value
|
||||
dataModel?.versionName?.observe(lifecycleOwner) {
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.vanced.manager.ui.viewmodels
|
||||
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.ComponentName
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
|
@ -71,6 +75,21 @@ open class HomeViewModel(private val activity: FragmentActivity): ViewModel() {
|
|||
InternetTools.openUrl(url, color, activity)
|
||||
}
|
||||
|
||||
fun launchApp(app: String, isRoot: Boolean) {
|
||||
val componentName = when (app) {
|
||||
activity.getString(R.string.vanced) -> if (isRoot) ComponentName(vancedRootPkg, "$vancedRootPkg.HomeActivity") else ComponentName(vancedPkg, "$vancedRootPkg.HomeActivity")
|
||||
activity.getString(R.string.music) -> if (isRoot) ComponentName(musicRootPkg, "$musicRootPkg.activities.MusicActivity") else ComponentName(musicPkg, "$musicRootPkg.activities.MusicActivity")
|
||||
activity.getString(R.string.microg) -> ComponentName(microgPkg, "org.microg.gms.ui.SettingsActivity")
|
||||
else -> throw IllegalArgumentException("Can't open this app")
|
||||
}
|
||||
try {
|
||||
activity.startActivity(Intent().setComponent(componentName))
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Log.d("VMHMV", e.toString())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun openInstallDialog(view: View, app: String) {
|
||||
val variant = prefs.getString("vanced_variant", "nonroot")
|
||||
if (variant == "nonroot" && app != activity.getString(R.string.microg) && !microg.value?.isAppInstalled?.value!!) {
|
||||
|
|
10
app/src/main/res/drawable/ic_baseline_launch_24.xml
Normal file
10
app/src/main/res/drawable/ic_baseline_launch_24.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M19,19H5V5h7V3H5c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2v-7h-2v7zM14,3v2h3.59l-9.83,9.83 1.41,1.41L19,6.41V10h2V3h-7z"/>
|
||||
</vector>
|
|
@ -48,6 +48,18 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/app_install_button"
|
||||
app:tint="?colorLinkImage" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/app_launch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/transparent"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/ic_baseline_launch_24"
|
||||
app:layout_constraintEnd_toStartOf="@id/app_uninstall"
|
||||
app:layout_constraintTop_toBottomOf="@id/app_install_button"
|
||||
android:layout_marginEnd="4dp"
|
||||
app:tint="?colorLinkImage" />
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout
|
||||
android:id="@+id/app_remote_version_container"
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in a new issue