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:
parent
33580abd18
commit
55f6ac8622
4 changed files with 139 additions and 126 deletions
|
@ -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() {
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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>
|
||||||
|
|
||||||
|
|
|
@ -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,18 +13,16 @@
|
||||||
|
|
||||||
</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"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
style="@style/MaterialCard"
|
style="@style/MaterialCard"
|
||||||
tools:ignore="ContentDescription, KeyboardInaccessibleWidget">
|
tools:ignore="ContentDescription, KeyboardInaccessibleWidget">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
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"
|
||||||
|
@ -32,48 +32,48 @@
|
||||||
android:id="@+id/home_vanced_logo"
|
android:id="@+id/home_vanced_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_vanced"
|
app:layout_constraintBottom_toTopOf="@id/vanced_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/vanced_title_buttons_barrier" />
|
app:srcCompat="@drawable/ic_vanced" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
style="@style/TextAppTitle"
|
style="@style/TextAppTitle"
|
||||||
android:text="@string/vanced"
|
android:text="@string/vanced"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/vanced_title_buttons_barrier"
|
||||||
app:layout_constraintStart_toEndOf="@id/home_vanced_logo"
|
app:layout_constraintStart_toEndOf="@id/home_vanced_logo"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
app:layout_constraintBottom_toTopOf="@id/vanced_title_buttons_barrier" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/vanced_installbtn"
|
android:id="@+id/vanced_installbtn"
|
||||||
style="@style/ButtonStyle"
|
style="@style/ButtonStyle"
|
||||||
android:text="@{viewModel.vancedInstallButtonTxt}"
|
android:text="@{viewModel.vancedInstallButtonTxt}"
|
||||||
|
app:icon="@{viewModel.vancedInstallButtonIcon}"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
app:icon="@{viewModel.vancedInstallButtonIcon}" />
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.Barrier
|
<androidx.constraintlayout.widget.Barrier
|
||||||
android:id="@+id/vanced_title_buttons_barrier"
|
android:id="@+id/vanced_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="home_vanced_logo, vanced_installbtn"/>
|
app:constraint_referenced_ids="home_vanced_logo, vanced_installbtn" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
style="@style/ClickableImageWidget.Red"
|
|
||||||
android:id="@+id/vanced_uninstallbtn"
|
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_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/vanced_title_buttons_barrier"
|
app:layout_constraintTop_toBottomOf="@id/vanced_title_buttons_barrier"
|
||||||
app:srcCompat="@drawable/ic_delete_black_24dp"
|
app:srcCompat="@drawable/ic_delete_black_24dp" />
|
||||||
android:visibility="@{viewModel.vancedInstalled ? View.VISIBLE : View.GONE}"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/vanced_remote_latest_version"
|
android:id="@+id/vanced_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_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintBottom_toTopOf="@id/linearLayout2"
|
app:layout_constraintBottom_toTopOf="@id/linearLayout2"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/vanced_title_buttons_barrier">
|
app:layout_constraintTop_toBottomOf="@+id/vanced_title_buttons_barrier">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -81,8 +81,8 @@
|
||||||
android:text="@string/latest" />
|
android:text="@string/latest" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
style="@style/AppVer.Bold"
|
|
||||||
android:id="@+id/vanced_latest_version"
|
android:id="@+id/vanced_latest_version"
|
||||||
|
style="@style/AppVer.Bold"
|
||||||
android:text="@{viewModel.vancedVersion}" />
|
android:text="@{viewModel.vancedVersion}" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -99,8 +99,8 @@
|
||||||
android:text="@string/version_installed" />
|
android:text="@string/version_installed" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
style="@style/AppVer.Bold"
|
|
||||||
android:id="@+id/vanced_installed_version"
|
android:id="@+id/vanced_installed_version"
|
||||||
|
style="@style/AppVer.Bold"
|
||||||
android:text="@{viewModel.vancedInstalledVersion}" />
|
android:text="@{viewModel.vancedInstalledVersion}" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -112,10 +112,10 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible"/>
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
</layout>
|
</layout>
|
Loading…
Reference in a new issue