mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-23 11:45:11 +00:00
attempt to fix 5 times touch detection
This commit is contained in:
parent
8e4e64cdf8
commit
fce1bdd1fa
4 changed files with 11 additions and 67 deletions
|
@ -6,6 +6,7 @@ import android.os.Bundle
|
||||||
import android.view.MotionEvent
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Button
|
import android.widget.Button
|
||||||
|
import android.widget.LinearLayout
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import com.google.android.material.card.MaterialCardView
|
import com.google.android.material.card.MaterialCardView
|
||||||
|
@ -21,8 +22,8 @@ open class About : BaseFragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
val aboutHeader: MaterialCardView = view.findViewById(R.id.about_header_wrapper)
|
val aboutHeader: LinearLayout = view.findViewById(R.id.about_header_layout)
|
||||||
aboutHeader.setOnTouchListener { _: View?, event: MotionEvent ->
|
aboutHeader.setOnTouchListener { _, event: MotionEvent ->
|
||||||
|
|
||||||
val eventAction = event.action
|
val eventAction = event.action
|
||||||
if (eventAction == MotionEvent.ACTION_UP) {
|
if (eventAction == MotionEvent.ACTION_UP) {
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
package com.vanced.manager.core.fragments;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import com.google.android.material.card.MaterialCardView;
|
|
||||||
import com.vanced.manager.R;
|
|
||||||
import com.vanced.manager.core.base.BaseFragment;
|
|
||||||
|
|
||||||
//This java code is stinky
|
|
||||||
public class about_7tap extends BaseFragment {
|
|
||||||
|
|
||||||
private int count = 0;
|
|
||||||
private long startMillSec = 0;
|
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
|
||||||
@Override
|
|
||||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
|
|
||||||
MaterialCardView aboutHeader = requireView().findViewById(R.id.about_header_wrapper);
|
|
||||||
aboutHeader.setOnTouchListener((v, event) -> {
|
|
||||||
|
|
||||||
int eventAction = event.getAction();
|
|
||||||
if (eventAction == MotionEvent.ACTION_UP) {
|
|
||||||
long time = System.currentTimeMillis();
|
|
||||||
if (startMillSec == 0 || (time - startMillSec > 3000)) {
|
|
||||||
|
|
||||||
startMillSec = time;
|
|
||||||
count = 1;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count == 5) {
|
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(requireContext());
|
|
||||||
prefs.edit().putBoolean("devSettings", true).apply();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -29,8 +29,8 @@ class MainActivity : Main() {
|
||||||
val appBarConfiguration = AppBarConfiguration(navHost.graph)
|
val appBarConfiguration = AppBarConfiguration(navHost.graph)
|
||||||
toolbar.setupWithNavController(navHost, appBarConfiguration)
|
toolbar.setupWithNavController(navHost, appBarConfiguration)
|
||||||
|
|
||||||
navHost.addOnDestinationChangedListener{_, currfrag: NavDestination, _ ->
|
navHost.addOnDestinationChangedListener{_, currFrag: NavDestination, _ ->
|
||||||
isParent = when (currfrag.id) {
|
isParent = when (currFrag.id) {
|
||||||
R.id.home_fragment -> true
|
R.id.home_fragment -> true
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ class MainActivity : Main() {
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
val navHost = findNavController(R.id.bottom_nav_host)
|
val navHost = findNavController(R.id.bottom_nav_host)
|
||||||
val prefs = PreferenceManager.getDefaultSharedPreferences(this)
|
val prefs = PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
val devSettings = prefs.getBoolean("devSettings", true)
|
val devSettings = prefs.getBoolean("devSettings", false)
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
android.R.id.home -> {
|
android.R.id.home -> {
|
||||||
onBackPressed()
|
onBackPressed()
|
||||||
|
@ -63,10 +63,11 @@ class MainActivity : Main() {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
R.id.dev_settings -> {
|
R.id.dev_settings -> {
|
||||||
if (devSettings) {
|
return if (devSettings) {
|
||||||
navHost.navigate(R.id.toDevSettingsFragment)
|
navHost.navigate(R.id.toDevSettingsFragment)
|
||||||
return true
|
true
|
||||||
} else super.onOptionsItemSelected(item)
|
} else
|
||||||
|
false
|
||||||
|
|
||||||
}
|
}
|
||||||
else -> super.onOptionsItemSelected(item)
|
else -> super.onOptionsItemSelected(item)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
app:cardCornerRadius="8dp">
|
app:cardCornerRadius="8dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/about_header_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/rectangle_2"
|
android:background="@drawable/rectangle_2"
|
||||||
|
|
Loading…
Reference in a new issue