From 2c46b509dc797f498eeb7b3151ef94846ddef40c Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Thu, 18 Jan 2018 17:12:45 -0600 Subject: [PATCH] Created ChildViewPager that does not listen to swipe events --- .../fragments/SecuritySettingsFragment.java | 4 +- .../crystalwallet/util/ChildViewPager.java | 48 +++++++++++++++++++ app/src/main/res/layout/activity_settings.xml | 4 +- .../main/res/layout/fragment_pin_security.xml | 38 +++++++++------ .../res/layout/fragment_security_settings.xml | 2 +- app/src/main/res/values/strings.xml | 5 ++ 6 files changed, 83 insertions(+), 18 deletions(-) create mode 100644 app/src/main/java/cy/agorise/crystalwallet/util/ChildViewPager.java diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/SecuritySettingsFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/SecuritySettingsFragment.java index c20e65d..3850627 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/SecuritySettingsFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/SecuritySettingsFragment.java @@ -13,6 +13,7 @@ import android.view.ViewGroup; import butterknife.BindView; import butterknife.ButterKnife; import cy.agorise.crystalwallet.R; +import cy.agorise.crystalwallet.util.ChildViewPager; /** * Created by xd on 1/17/18. @@ -32,7 +33,7 @@ public class SecuritySettingsFragment extends Fragment { } @BindView(R.id.pager) - public ViewPager mPager; + public ChildViewPager mPager; public SecurityPagerAdapter securityPagerAdapter; @@ -45,6 +46,7 @@ public class SecuritySettingsFragment extends Fragment { securityPagerAdapter = new SecurityPagerAdapter(getChildFragmentManager()); mPager.setAdapter(securityPagerAdapter); + mPager.setSwipeLocked(true); TabLayout tabLayout = v.findViewById(R.id.tabs); diff --git a/app/src/main/java/cy/agorise/crystalwallet/util/ChildViewPager.java b/app/src/main/java/cy/agorise/crystalwallet/util/ChildViewPager.java new file mode 100644 index 0000000..d01cbd5 --- /dev/null +++ b/app/src/main/java/cy/agorise/crystalwallet/util/ChildViewPager.java @@ -0,0 +1,48 @@ +package cy.agorise.crystalwallet.util; + +import android.content.Context; +import android.support.v4.view.ViewPager; +import android.util.AttributeSet; +import android.view.MotionEvent; + +/** + * Created by xd on 1/18/18. + */ + + +public class ChildViewPager extends ViewPager { + + private boolean swipeLocked; + + public ChildViewPager(Context context) { + super(context); + } + + public ChildViewPager(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public boolean getSwipeLocked() { + return swipeLocked; + } + + public void setSwipeLocked(boolean swipeLocked) { + this.swipeLocked = swipeLocked; + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + return !swipeLocked && super.onTouchEvent(event); + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent event) { + return !swipeLocked && super.onInterceptTouchEvent(event); + } + + @Override + public boolean canScrollHorizontally(int direction) { + return !swipeLocked && super.canScrollHorizontally(direction); + } + +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index a53ac71..484c17d 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -139,7 +139,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="24dp" - android:text="v2.0.0" + android:text="@string/version_placeholder" android:textSize="16sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -148,7 +148,7 @@ - + android:layout_height="match_parent"> + app:layout_constraintVertical_chainStyle="packed" /> + app:layout_constraintTop_toBottomOf="@+id/tvCurrentPin" + tools:ignore="LabelFor" /> + app:layout_constraintTop_toBottomOf="@+id/etCurrentPin" /> + app:layout_constraintTop_toBottomOf="@+id/etNewPin" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_security_settings.xml b/app/src/main/res/layout/fragment_security_settings.xml index 0e513fb..0c2f9ce 100644 --- a/app/src/main/res/layout/fragment_security_settings.xml +++ b/app/src/main/res/layout/fragment_security_settings.xml @@ -54,7 +54,7 @@ - Remove an account from this Wallet. The account removed will still reside on the blockchain. Remove user_name Password + v1.0 + block# 14966596 + Current PIN + New PIN + Confirm PIN