0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-27 13:33:00 +00:00

Copy version when MaterialCardView tapped

This commit is contained in:
AioiLight 2020-07-04 02:46:09 +09:00
parent 33580abd18
commit 55f6ac8622
4 changed files with 139 additions and 126 deletions

View file

@ -1,9 +1,6 @@
package com.vanced.manager.ui.fragments package com.vanced.manager.ui.fragments
import android.content.BroadcastReceiver import android.content.*
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
@ -11,12 +8,14 @@ import android.view.*
import android.view.animation.AccelerateDecelerateInterpolator import android.view.animation.AccelerateDecelerateInterpolator
import android.widget.ImageButton import android.widget.ImageButton
import android.widget.ProgressBar import android.widget.ProgressBar
import android.widget.Toast
import androidx.databinding.DataBindingUtil import androidx.databinding.DataBindingUtil
import androidx.fragment.app.viewModels import androidx.fragment.app.viewModels
import androidx.localbroadcastmanager.content.LocalBroadcastManager import androidx.localbroadcastmanager.content.LocalBroadcastManager
import androidx.preference.PreferenceManager.getDefaultSharedPreferences import androidx.preference.PreferenceManager.getDefaultSharedPreferences
import androidx.viewpager2.widget.ViewPager2 import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.button.MaterialButton import com.google.android.material.button.MaterialButton
import com.google.android.material.card.MaterialCardView
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator import com.google.android.material.tabs.TabLayoutMediator
import com.vanced.manager.R import com.vanced.manager.R
@ -62,6 +61,20 @@ class HomeFragment : Home() {
view.findViewById<ImageButton>(R.id.changelog_button).setOnClickListener { view.findViewById<ImageButton>(R.id.changelog_button).setOnClickListener {
cardExpandCollapse() cardExpandCollapse()
} }
view.findViewById<MaterialCardView>(R.id.vanced_card).setOnLongClickListener{
val clip = activity?.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
clip.setPrimaryClip(ClipData.newPlainText("vanced", viewModel.vancedInstalledVersion.value))
Toast.makeText(activity,"Vanced version was copied!", Toast.LENGTH_LONG).show()
true
}
view.findViewById<MaterialCardView>(R.id.microg_card).setOnLongClickListener{
val clip = activity?.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
clip.setPrimaryClip(ClipData.newPlainText("microg", viewModel.microgInstalledVersion.value))
Toast.makeText(activity,"MicroG version was copied!", Toast.LENGTH_LONG).show()
true
}
} }
private fun cardExpandCollapse() { private fun cardExpandCollapse() {

View file

@ -96,7 +96,6 @@
bind:viewModel="@{viewModel}"/> bind:viewModel="@{viewModel}"/>
<include <include
android:id="@+id/home_microg_wrapper"
layout="@layout/include_microg" layout="@layout/include_microg"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -104,7 +103,7 @@
android:layout_marginTop="@dimen/stdp" android:layout_marginTop="@dimen/stdp"
android:layout_marginEnd="@dimen/stdp" android:layout_marginEnd="@dimen/stdp"
android:visibility="@{viewModel.nonrootModeSelected ? View.VISIBLE : View.GONE}" android:visibility="@{viewModel.nonrootModeSelected ? View.VISIBLE : View.GONE}"
bind:viewModel="@{viewModel}"/> bind:viewModel="@{viewModel}" />
<include <include
layout="@layout/include_changelogs" layout="@layout/include_changelogs"

View file

@ -15,13 +15,14 @@
</data> </data>
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
android:id="@+id/microg_card"
style="@style/MaterialCard"> style="@style/MaterialCard">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:animateLayoutChanges="true"
android:animateLayoutChanges="true"> android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -31,49 +32,49 @@
android:id="@+id/home_microg_logo" android:id="@+id/home_microg_logo"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_microg" app:layout_constraintBottom_toTopOf="@id/microg_title_buttons_barrier"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/microg_title_buttons_barrier" /> app:srcCompat="@drawable/ic_microg" />
<TextView <TextView
style="@style/TextAppTitle" style="@style/TextAppTitle"
android:text="@string/microg" android:text="@string/microg"
app:layout_constraintBottom_toTopOf="@id/microg_title_buttons_barrier"
app:layout_constraintStart_toEndOf="@id/home_microg_logo" app:layout_constraintStart_toEndOf="@id/home_microg_logo"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintBottom_toTopOf="@id/microg_title_buttons_barrier" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/microg_installbtn" android:id="@+id/microg_installbtn"
style="@style/ButtonStyle" style="@style/ButtonStyle"
android:text="@{viewModel.microgInstallButtonTxt}" android:text="@{viewModel.microgInstallButtonTxt}"
app:icon="@{viewModel.microgInstallButtonIcon}" app:icon="@{viewModel.microgInstallButtonIcon}"
app:layout_constraintBottom_toTopOf="@id/microg_uninstallbtn"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintBottom_toTopOf="@id/microg_uninstallbtn" />
<androidx.constraintlayout.widget.Barrier <androidx.constraintlayout.widget.Barrier
android:id="@+id/microg_title_buttons_barrier" android:id="@+id/microg_title_buttons_barrier"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:barrierDirection="bottom" app:barrierDirection="bottom"
app:constraint_referenced_ids="microg_installbtn"/> app:constraint_referenced_ids="microg_installbtn" />
<LinearLayout <LinearLayout
android:id="@+id/microg_remote_latest_version" android:id="@+id/microg_remote_latest_version"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@id/linearLayout2"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/microg_title_buttons_barrier" app:layout_constraintTop_toBottomOf="@+id/microg_title_buttons_barrier">
app:layout_constraintBottom_toTopOf="@id/linearLayout2">
<TextView <TextView
style="@style/AppVer" style="@style/AppVer"
android:text="@string/latest" /> android:text="@string/latest" />
<TextView <TextView
style="@style/AppVer.Bold"
android:id="@+id/microg_latest_version" android:id="@+id/microg_latest_version"
style="@style/AppVer.Bold"
android:text="@{viewModel.microgVersion}" /> android:text="@{viewModel.microgVersion}" />
</LinearLayout> </LinearLayout>
@ -82,40 +83,40 @@
android:id="@+id/linearLayout2" android:id="@+id/linearLayout2"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/microg_remote_latest_version" app:layout_constraintTop_toBottomOf="@id/microg_remote_latest_version">
app:layout_constraintBottom_toBottomOf="parent">
<TextView <TextView
style="@style/AppVer" style="@style/AppVer"
android:text="@string/version_installed" /> android:text="@string/version_installed" />
<TextView <TextView
style="@style/AppVer.Bold"
android:id="@+id/microg_installed_version" android:id="@+id/microg_installed_version"
style="@style/AppVer.Bold"
android:text="@{viewModel.microgInstalledVersion}" /> android:text="@{viewModel.microgInstalledVersion}" />
</LinearLayout> </LinearLayout>
<ImageView <ImageView
style="@style/ClickableImageWidget"
android:id="@+id/microg_settingsbtn" android:id="@+id/microg_settingsbtn"
app:srcCompat="@drawable/ic_microg_settings" style="@style/ClickableImageWidget"
android:layout_marginEnd="4dp"
android:onClick="@{()-> viewModel.openMicrogSettings()}"
android:visibility="@{viewModel.microgInstalled ? View.VISIBLE : View.GONE}"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/microg_uninstallbtn" app:layout_constraintEnd_toStartOf="@id/microg_uninstallbtn"
app:layout_constraintTop_toBottomOf="@id/microg_title_buttons_barrier" app:layout_constraintTop_toBottomOf="@id/microg_title_buttons_barrier"
android:layout_marginEnd="4dp" app:srcCompat="@drawable/ic_microg_settings" />
android:onClick="@{()-> viewModel.openMicrogSettings()}"
android:visibility="@{viewModel.microgInstalled ? View.VISIBLE : View.GONE}" />
<ImageView <ImageView
style="@style/ClickableImageWidget.Red"
android:id="@+id/microg_uninstallbtn" android:id="@+id/microg_uninstallbtn"
app:srcCompat="@drawable/ic_delete_black_24dp" style="@style/ClickableImageWidget.Red"
android:visibility="@{viewModel.microgInstalled ? View.VISIBLE : View.GONE}"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/microg_title_buttons_barrier" app:layout_constraintTop_toBottomOf="@id/microg_title_buttons_barrier"
android:visibility="@{viewModel.microgInstalled ? View.VISIBLE : View.GONE}" /> app:srcCompat="@drawable/ic_delete_black_24dp" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layout> <layout 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">
<data> <data>
@ -11,111 +13,109 @@
</data> </data>
<com.google.android.material.card.MaterialCardView <com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/vanced_card"
xmlns:app="http://schemas.android.com/apk/res-auto" style="@style/MaterialCard"
xmlns:tools="http://schemas.android.com/tools" tools:ignore="ContentDescription, KeyboardInaccessibleWidget">
style="@style/MaterialCard"
tools:ignore="ContentDescription, KeyboardInaccessibleWidget">
<LinearLayout <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:animateLayoutChanges="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:orientation="vertical">
<ImageView <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/home_vanced_logo" android:layout_width="match_parent"
android:layout_width="wrap_content" android:layout_height="wrap_content">
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_vanced"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/vanced_title_buttons_barrier" />
<TextView <ImageView
style="@style/TextAppTitle" android:id="@+id/home_vanced_logo"
android:text="@string/vanced" android:layout_width="wrap_content"
app:layout_constraintStart_toEndOf="@id/home_vanced_logo" android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toTopOf="@id/vanced_title_buttons_barrier"
app:layout_constraintBottom_toTopOf="@id/vanced_title_buttons_barrier" /> app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_vanced" />
<com.google.android.material.button.MaterialButton <TextView
android:id="@+id/vanced_installbtn" style="@style/TextAppTitle"
style="@style/ButtonStyle" android:text="@string/vanced"
android:text="@{viewModel.vancedInstallButtonTxt}" app:layout_constraintBottom_toTopOf="@id/vanced_title_buttons_barrier"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/home_vanced_logo"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent" />
app:icon="@{viewModel.vancedInstallButtonIcon}" />
<androidx.constraintlayout.widget.Barrier <com.google.android.material.button.MaterialButton
android:id="@+id/vanced_title_buttons_barrier" android:id="@+id/vanced_installbtn"
style="@style/ButtonStyle"
android:text="@{viewModel.vancedInstallButtonTxt}"
app:icon="@{viewModel.vancedInstallButtonIcon}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/vanced_title_buttons_barrier"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="home_vanced_logo, vanced_installbtn" />
<ImageView
android:id="@+id/vanced_uninstallbtn"
style="@style/ClickableImageWidget.Red"
android:visibility="@{viewModel.vancedInstalled ? View.VISIBLE : View.GONE}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/vanced_title_buttons_barrier"
app:srcCompat="@drawable/ic_delete_black_24dp" />
<LinearLayout
android:id="@+id/vanced_remote_latest_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@id/linearLayout2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vanced_title_buttons_barrier">
<TextView
style="@style/AppVer"
android:text="@string/latest" />
<TextView
android:id="@+id/vanced_latest_version"
style="@style/AppVer.Bold"
android:text="@{viewModel.vancedVersion}" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vanced_remote_latest_version">
<TextView
style="@style/AppVer"
android:text="@string/version_installed" />
<TextView
android:id="@+id/vanced_installed_version"
style="@style/AppVer.Bold"
android:text="@{viewModel.vancedInstalledVersion}" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<ProgressBar
android:id="@+id/vanced_installing"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:barrierDirection="bottom" android:visibility="gone"
app:constraint_referenced_ids="home_vanced_logo, vanced_installbtn"/> tools:visibility="visible" />
<ImageView </LinearLayout>
style="@style/ClickableImageWidget.Red"
android:id="@+id/vanced_uninstallbtn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/vanced_title_buttons_barrier"
app:srcCompat="@drawable/ic_delete_black_24dp"
android:visibility="@{viewModel.vancedInstalled ? View.VISIBLE : View.GONE}"/>
<LinearLayout </com.google.android.material.card.MaterialCardView>
android:id="@+id/vanced_remote_latest_version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@id/linearLayout2"
app:layout_constraintTop_toBottomOf="@+id/vanced_title_buttons_barrier">
<TextView
style="@style/AppVer"
android:text="@string/latest" />
<TextView
style="@style/AppVer.Bold"
android:id="@+id/vanced_latest_version"
android:text="@{viewModel.vancedVersion}" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vanced_remote_latest_version">
<TextView
style="@style/AppVer"
android:text="@string/version_installed" />
<TextView
style="@style/AppVer.Bold"
android:id="@+id/vanced_installed_version"
android:text="@{viewModel.vancedInstalledVersion}" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<ProgressBar
android:id="@+id/vanced_installing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
tools:visibility="visible"/>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</layout> </layout>