From c21fb6786f03c141fcfa4b1be712c4b79aeb9836 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Thu, 18 Jan 2018 13:39:05 -0600 Subject: [PATCH] Added viewpager to work inside SecuritySettingsFragment --- .../fragments/SecuritySettingsFragment.java | 44 ++++++++ .../res/layout/fragment_security_settings.xml | 106 ++++++++++++++++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 151 insertions(+) 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 471200c..e47e8c3 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/SecuritySettingsFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/SecuritySettingsFragment.java @@ -1,11 +1,16 @@ package cy.agorise.crystalwallet.fragments; import android.os.Bundle; +import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import butterknife.BindView; import butterknife.ButterKnife; import cy.agorise.crystalwallet.R; @@ -26,6 +31,11 @@ public class SecuritySettingsFragment extends Fragment { return fragment; } + @BindView(R.id.pager) + public ViewPager mPager; + + public SecurityPagerAdapter securityPagerAdapter; + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -33,6 +43,40 @@ public class SecuritySettingsFragment extends Fragment { View v = inflater.inflate(R.layout.fragment_security_settings, container, false); ButterKnife.bind(this, v); + securityPagerAdapter = new SecurityPagerAdapter(getChildFragmentManager()); + mPager.setAdapter(securityPagerAdapter); + + TabLayout tabLayout = v.findViewById(R.id.tabs); + + mPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); + tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mPager)); + return v; } + + private class SecurityPagerAdapter extends FragmentPagerAdapter { + SecurityPagerAdapter(FragmentManager fm) { + super(fm); + } + + @Override + public Fragment getItem(int position) { + switch (position){ + case 0: + //return new GeneralSettingsFragment(); + case 1: + //return new SecuritySettingsFragment(); + case 2: + return new BackupsSettingsFragment(); + } + + + return null; //new OnConstructionFragment(); + } + + @Override + public int getCount() { + return 3; + } + } } diff --git a/app/src/main/res/layout/fragment_security_settings.xml b/app/src/main/res/layout/fragment_security_settings.xml index d3a737e..0e513fb 100644 --- a/app/src/main/res/layout/fragment_security_settings.xml +++ b/app/src/main/res/layout/fragment_security_settings.xml @@ -1,7 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index af5eeb8..85457e3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -486,4 +486,5 @@ Refresh Remove an account from this Wallet. The account removed will still reside on the blockchain. Remove + user_name Password