mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-25 12:45:12 +00:00
Merge pull request #523 from cl-ement05/dev
added an AppUninstallDialog
This commit is contained in:
commit
c5a92d51b2
4 changed files with 104 additions and 1 deletions
|
@ -18,6 +18,7 @@ import com.vanced.manager.databinding.ViewAppExpandableBinding
|
|||
import com.vanced.manager.model.ButtonTag
|
||||
import com.vanced.manager.model.DataModel
|
||||
import com.vanced.manager.ui.dialogs.AppInfoDialog
|
||||
import com.vanced.manager.ui.dialogs.AppUninstallDialog
|
||||
import com.vanced.manager.ui.viewmodels.HomeViewModel
|
||||
import com.vanced.manager.utils.*
|
||||
|
||||
|
@ -64,7 +65,7 @@ class ExpandableAppListAdapter(
|
|||
}
|
||||
}
|
||||
appUninstall.setOnClickListener {
|
||||
dataModel?.appPkg?.let { it1 -> viewModel.uninstallPackage(it1) }
|
||||
AppUninstallDialog.newInstance(apps[position]).show(activity.supportFragmentManager, null)
|
||||
}
|
||||
appLaunch.setOnClickListener {
|
||||
viewModel.launchApp(apps[position], isRoot)
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package com.vanced.manager.ui.dialogs
|
||||
|
||||
import android.app.Activity
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.core.ui.base.BindingDialogFragment
|
||||
import com.vanced.manager.databinding.DialogAppUninstallBinding
|
||||
|
||||
class AppUninstallDialog : BindingDialogFragment<DialogAppUninstallBinding>() {
|
||||
|
||||
companion object {
|
||||
|
||||
private var TAG_APP_NAME: String? = null
|
||||
|
||||
fun newInstance(appName: String?) : AppUninstallDialog = AppUninstallDialog().apply {
|
||||
arguments = Bundle().apply {
|
||||
TAG_APP_NAME = appName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun binding(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
) = DialogAppUninstallBinding.inflate(inflater, container, false)
|
||||
|
||||
override fun otherSetups() {
|
||||
dialog?.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||
bindData()
|
||||
}
|
||||
|
||||
private fun bindData() {
|
||||
with(binding) {
|
||||
appUninstallConfirm.setOnClickListener {
|
||||
//uninstall instruction ??
|
||||
//dataModel?.appPkg?.let { it1 -> viewModel.uninstallPackage(it1) } (taken from original ExpandanbleAppListAdapter.kt)
|
||||
//but uninstallPackage method is not static so I would be forced to spawn a new HomeViewModel instance
|
||||
}
|
||||
appUninstallCancel.setOnClickListener {
|
||||
dismiss()
|
||||
}
|
||||
appUninstallMessage.text = getString(R.string.uninstall_app_text, TAG_APP_NAME)
|
||||
}
|
||||
}
|
||||
}
|
50
app/src/main/res/layout/dialog_app_uninstall.xml
Normal file
50
app/src/main/res/layout/dialog_app_uninstall.xml
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context=".ui.dialogs.AppUninstallDialog"
|
||||
android:keepScreenOn="true"
|
||||
style="@style/DialogCard">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app_uninstall_header"
|
||||
style="@style/DialogCardTitle"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/uninstall"
|
||||
android:textAlignment="center" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/app_uninstall_message"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/uninstall_app_text"
|
||||
style="@style/DialogCardSubtitle"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp" >
|
||||
|
||||
<com.vanced.manager.ui.core.ThemedOutlinedMaterialButton
|
||||
android:id="@+id/app_uninstall_cancel"
|
||||
style="@style/OutlinedButtonStyle"
|
||||
android:layout_alignParentStart="true"
|
||||
android:text="@string/cancel" />
|
||||
|
||||
<com.vanced.manager.ui.core.ThemedMaterialButton
|
||||
android:id="@+id/app_uninstall_confirm"
|
||||
style="@style/ButtonStyle"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:text="@string/uninstall" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
|
@ -91,6 +91,8 @@
|
|||
<string name="miui_one">To install Vanced, you MUST disable MIUI Optimizations in the developer settings. (You can ignore this warning if you are using 20.2.20 or later xiaomi.eu based ROM)</string>
|
||||
<string name="miui_one_title">MIUI Optimizations are enabled!</string>
|
||||
<string name="please_be_patient">Please do NOT exit the app during this process!</string>
|
||||
<string name="uninstall_app_text">Are you sure you want to uninstall %1$s ?</string>
|
||||
<string name="uninstall">Uninstall</string>
|
||||
<string name="redownload">Redownload</string>
|
||||
<string name="security_context">Make sure that you downloaded the app from vancedapp.com, the Vanced Discord server, or the Vanced GitHub</string>
|
||||
<string name="version">Version</string>
|
||||
|
|
Loading…
Reference in a new issue