0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-28 22:13:01 +00:00

Added button info on long press

This commit is contained in:
X1nto 2021-04-17 13:16:46 +04:00
parent b5b577cf8b
commit 7e3edb9cb6
7 changed files with 81 additions and 38 deletions

View file

@ -15,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.card.MaterialCardView import com.google.android.material.card.MaterialCardView
import com.vanced.manager.R import com.vanced.manager.R
import com.vanced.manager.databinding.ViewAppExpandableBinding import com.vanced.manager.databinding.ViewAppExpandableBinding
import com.vanced.manager.model.ButtonTag
import com.vanced.manager.model.DataModel import com.vanced.manager.model.DataModel
import com.vanced.manager.ui.dialogs.AppInfoDialog import com.vanced.manager.ui.dialogs.AppInfoDialog
import com.vanced.manager.ui.viewmodels.HomeViewModel import com.vanced.manager.ui.viewmodels.HomeViewModel
@ -42,8 +43,15 @@ class ExpandableAppListAdapter(
appTitle.text = dataModel?.appName appTitle.text = dataModel?.appName
appDescription.text = dataModel?.appDescription appDescription.text = dataModel?.appDescription
dataModel?.appIcon?.let { appIcon.setImageResource(it) } dataModel?.appIcon?.let { appIcon.setImageResource(it) }
appDownload.setOnClickListener { appDownload.apply {
viewModel.openInstallDialog(dataModel?.buttonTag?.value, apps[position]) val buttonTag = dataModel?.buttonTag?.value
setOnClickListener { viewModel.openInstallDialog(buttonTag, apps[position]) }
contentDescription = activity.getString(
if (buttonTag == ButtonTag.UPDATE)
R.string.accessibility_update
else
R.string.accessibility_download
)
} }
appClickableLayout.setOnClickListener { appClickableLayout.setOnClickListener {
if (isAnimationRunning) return@setOnClickListener if (isAnimationRunning) return@setOnClickListener
@ -90,7 +98,7 @@ class ExpandableAppListAdapter(
} }
dataModel?.buttonImage?.observe(activity) { dataModel?.buttonImage?.observe(activity) {
if (it != null) { if (it != null) {
appDownload.setImageDrawable(it) appDownload.icon = it
} }
} }
} }

View file

@ -0,0 +1,25 @@
package com.vanced.manager.ui.core
import android.content.Context
import android.content.res.ColorStateList
import android.util.AttributeSet
import android.widget.Toast
import androidx.appcompat.widget.AppCompatImageButton
import com.google.android.material.button.MaterialButton
import com.vanced.manager.utils.accentColor
class ThemedIconButton @JvmOverloads constructor(
context: Context,
attributeSet: AttributeSet? = null,
defStyleAttr: Int = 0
) : MaterialButton(context, attributeSet, defStyleAttr) {
init {
iconTint = ColorStateList.valueOf(accentColor.value!!)
setOnLongClickListener {
Toast.makeText(context, contentDescription, Toast.LENGTH_SHORT).show()
true
}
}
}

View file

@ -1,19 +0,0 @@
package com.vanced.manager.ui.core
import android.content.Context
import android.content.res.ColorStateList
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatImageButton
import com.vanced.manager.utils.accentColor
class ThemedImageButton @JvmOverloads constructor(
context: Context,
attributeSet: AttributeSet? = null,
defStyleAttr: Int = 0
) : AppCompatImageButton(context, attributeSet, defStyleAttr) {
init {
imageTintList = ColorStateList.valueOf(accentColor.value!!)
}
}

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@android:color/darker_gray">
<item android:id="@android:id/mask">
<shape android:shape="oval" >
<solid android:color="@android:color/transparent" />
</shape>
</item>
</ripple>

View file

@ -14,8 +14,8 @@
android:id="@+id/app_expanded_view" android:id="@+id/app_expanded_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingHorizontal="16dp" android:paddingVertical="8dp"
android:paddingVertical="12dp" android:paddingHorizontal="12dp"
android:alpha="0" android:alpha="0"
android:scaleX="0.8" android:scaleX="0.8"
android:scaleY="0.8" android:scaleY="0.8"
@ -75,37 +75,41 @@
app:flexWrap="wrap" app:flexWrap="wrap"
app:flexDirection="row_reverse"> app:flexDirection="row_reverse">
<com.vanced.manager.ui.core.ThemedImageButton <com.vanced.manager.ui.core.ThemedIconButton
android:id="@+id/app_download" android:id="@+id/app_download"
style="@style/AppActionButton" style="@style/AppActionButton"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
android:src="@drawable/ic_app_download"/> app:icon="@drawable/ic_app_download"
android:contentDescription="@string/accessibility_download"/>
<com.vanced.manager.ui.core.ThemedImageButton <com.vanced.manager.ui.core.ThemedIconButton
android:id="@+id/app_launch" android:id="@+id/app_launch"
style="@style/AppActionButton" style="@style/AppActionButton"
app:layout_constraintEnd_toStartOf="@id/app_download" app:layout_constraintEnd_toStartOf="@id/app_download"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
android:src="@drawable/ic_baseline_launch_24"/> app:icon="@drawable/ic_baseline_launch_24"
android:contentDescription="@string/accessibility_launch"/>
<com.vanced.manager.ui.core.ThemedImageButton <com.vanced.manager.ui.core.ThemedIconButton
android:id="@+id/app_uninstall" android:id="@+id/app_uninstall"
style="@style/AppActionButton" style="@style/AppActionButton"
app:layout_constraintEnd_toStartOf="@id/app_launch" app:layout_constraintEnd_toStartOf="@id/app_launch"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
android:src="@drawable/ic_app_uninstall"/> app:icon="@drawable/ic_app_uninstall"
android:contentDescription="@string/accessibility_uninstall"/>
<com.vanced.manager.ui.core.ThemedImageButton <com.vanced.manager.ui.core.ThemedIconButton
android:id="@+id/app_info" android:id="@+id/app_info"
style="@style/AppActionButton" style="@style/AppActionButton"
app:layout_constraintEnd_toStartOf="@id/app_uninstall" app:layout_constraintEnd_toStartOf="@id/app_uninstall"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
android:src="@drawable/ic_app_info"/> app:icon="@drawable/ic_app_info"
android:contentDescription="@string/accessibility_info"/>
</com.google.android.flexbox.FlexboxLayout> </com.google.android.flexbox.FlexboxLayout>
@ -115,7 +119,7 @@
android:id="@+id/app_clickable_layout" android:id="@+id/app_clickable_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:contentPadding="16dp" app:contentPadding="12dp"
app:cardCornerRadius="0dp" app:cardCornerRadius="0dp"
app:cardElevation="0dp" app:cardElevation="0dp"
app:cardBackgroundColor="?colorLinkBG" app:cardBackgroundColor="?colorLinkBG"

View file

@ -28,6 +28,11 @@
<!-- Home Page --> <!-- Home Page -->
<string name="about_app">About %1$s</string> <string name="about_app">About %1$s</string>
<string name="accessibility_download">Download</string>
<string name="accessibility_info">Info</string>
<string name="accessibility_launch">Launch</string>
<string name="accessibility_uninstall">Uninstall</string>
<string name="accessibility_update">Update</string>
<string name="apps">Apps</string> <string name="apps">Apps</string>
<string name="changelog">Changelog</string> <string name="changelog">Changelog</string>
<string name="downloading_file">Downloading %1$s</string> <string name="downloading_file">Downloading %1$s</string>

View file

@ -22,11 +22,22 @@
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
</style> </style>
<style name="AppActionButton" parent="Widget.AppCompat.ImageButton"> <style name="AppActionButton" parent="Widget.MaterialComponents.Button.OutlinedButton">
<item name="android:layout_width">wrap_content</item> <item name="android:layout_width">36dp</item>
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">36dp</item>
<item name="android:layout_marginEnd">8dp</item> <item name="iconPadding">0dp</item>
<item name="android:background">@android:color/transparent</item> <item name="iconGravity">textStart</item>
<item name="cornerRadius">20dp</item>
<item name="android:shadowColor">@android:color/transparent</item>
<item name="strokeColor">@android:color/transparent</item>
<item name="android:insetBottom">0dp</item>
<item name="android:insetTop">0dp</item>
<item name="android:insetLeft">0dp</item>
<item name="android:insetRight">0dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:paddingTop">0dp</item>
<item name="android:paddingLeft">0dp</item>
<item name="android:paddingRight">0dp</item>
</style> </style>
<style name="AppVersionText" parent="Widget.MaterialComponents.TextView"> <style name="AppVersionText" parent="Widget.MaterialComponents.TextView">