0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-27 05:23: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
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.*
import android.content.res.ColorStateList
import android.graphics.Color
import android.os.Bundle
@ -11,12 +8,14 @@ import android.view.*
import android.view.animation.AccelerateDecelerateInterpolator
import android.widget.ImageButton
import android.widget.ProgressBar
import android.widget.Toast
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.viewModels
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
import androidx.viewpager2.widget.ViewPager2
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.TabLayoutMediator
import com.vanced.manager.R
@ -62,6 +61,20 @@ class HomeFragment : Home() {
view.findViewById<ImageButton>(R.id.changelog_button).setOnClickListener {
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() {

View file

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

View file

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

View file

@ -1,5 +1,7 @@
<?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>
@ -11,18 +13,16 @@
</data>
<com.google.android.material.card.MaterialCardView
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"
<com.google.android.material.card.MaterialCardView
android:id="@+id/vanced_card"
style="@style/MaterialCard"
tools:ignore="ContentDescription, KeyboardInaccessibleWidget">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:animateLayoutChanges="true">
android:animateLayoutChanges="true"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
@ -32,48 +32,48 @@
android:id="@+id/home_vanced_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_vanced"
app:layout_constraintBottom_toTopOf="@id/vanced_title_buttons_barrier"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/vanced_title_buttons_barrier" />
app:srcCompat="@drawable/ic_vanced" />
<TextView
style="@style/TextAppTitle"
android:text="@string/vanced"
app:layout_constraintBottom_toTopOf="@id/vanced_title_buttons_barrier"
app:layout_constraintStart_toEndOf="@id/home_vanced_logo"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/vanced_title_buttons_barrier" />
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.button.MaterialButton
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"
app:icon="@{viewModel.vancedInstallButtonIcon}" />
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"/>
app:constraint_referenced_ids="home_vanced_logo, vanced_installbtn" />
<ImageView
style="@style/ClickableImageWidget.Red"
android:id="@+id/vanced_uninstallbtn"
app:layout_constraintEnd_toEndOf="parent"
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"
android:visibility="@{viewModel.vancedInstalled ? View.VISIBLE : View.GONE}"/>
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_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@id/linearLayout2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vanced_title_buttons_barrier">
<TextView
@ -81,8 +81,8 @@
android:text="@string/latest" />
<TextView
style="@style/AppVer.Bold"
android:id="@+id/vanced_latest_version"
style="@style/AppVer.Bold"
android:text="@{viewModel.vancedVersion}" />
</LinearLayout>
@ -99,8 +99,8 @@
android:text="@string/version_installed" />
<TextView
style="@style/AppVer.Bold"
android:id="@+id/vanced_installed_version"
style="@style/AppVer.Bold"
android:text="@{viewModel.vancedInstalledVersion}" />
</LinearLayout>
@ -112,10 +112,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
tools:visibility="visible"/>
tools:visibility="visible" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.card.MaterialCardView>
</layout>