Added viewpager to work inside SecuritySettingsFragment

This commit is contained in:
Severiano Jaramillo 2018-01-18 13:39:05 -06:00
parent d7ce6e6088
commit 72fc4d507a
3 changed files with 151 additions and 0 deletions

View file

@ -1,11 +1,16 @@
package cy.agorise.crystalwallet.fragments; package cy.agorise.crystalwallet.fragments;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment; 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.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.R;
@ -26,6 +31,11 @@ public class SecuritySettingsFragment extends Fragment {
return fragment; return fragment;
} }
@BindView(R.id.pager)
public ViewPager mPager;
public SecurityPagerAdapter securityPagerAdapter;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
@ -33,6 +43,40 @@ public class SecuritySettingsFragment extends Fragment {
View v = inflater.inflate(R.layout.fragment_security_settings, container, false); View v = inflater.inflate(R.layout.fragment_security_settings, container, false);
ButterKnife.bind(this, v); 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; 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;
}
}
} }

View file

@ -1,7 +1,113 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout <android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" 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"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="24dp"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@+id/vPocketSecurity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/lightGray"
app:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabTextColor="@color/black"
android:animateLayoutChanges="true">
<android.support.design.widget.TabItem
android:id="@+id/tabNone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="None" />
<android.support.design.widget.TabItem
android:id="@+id/tabPin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pin" />
<android.support.design.widget.TabItem
android:id="@+id/tabPattern"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pattern" />
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
<View
android:id="@+id/vPocketSecurity"
android:layout_width="match_parent"
android:layout_height="140dp"
android:background="@color/lightGray"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/tvPocketSecurity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginStart="24dp"
android:text="Use &quot;Pocket&quot; Security"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintTop_toTopOf="@+id/vPocketSecurity"
app:layout_constraintStart_toStartOf="@id/vPocketSecurity"/>
<Switch
android:id="@+id/sPocketSecurity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginTop="24dp"
app:layout_constraintTop_toTopOf="@+id/vPocketSecurity"
app:layout_constraintEnd_toEndOf="@id/vPocketSecurity" />
<TextView
android:id="@+id/tvPocketSecurityUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/user_name_password_placeholder"
tools:layout_editor_absoluteY="8dp"
app:layout_constraintTop_toBottomOf="@id/tvPocketSecurity"
app:layout_constraintStart_toStartOf="@id/tvPocketSecurity"/>
<EditText
android:id="@+id/etPocketPassword"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/tvPocketSecurityUser"
app:layout_constraintStart_toStartOf="@id/tvPocketSecurity"
app:layout_constraintEnd_toEndOf="@id/sPocketSecurity"/>
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>

View file

@ -486,4 +486,5 @@
<string name="refresh">Refresh</string> <string name="refresh">Refresh</string>
<string name="remove_description">Remove an account from this Wallet. The account removed will still reside on the blockchain.</string> <string name="remove_description">Remove an account from this Wallet. The account removed will still reside on the blockchain.</string>
<string name="remove">Remove</string> <string name="remove">Remove</string>
<string name="user_name_password_placeholder">user_name Password</string>
</resources> </resources>