Added viewpager to work inside SecuritySettingsFragment
This commit is contained in:
parent
c7890db123
commit
c21fb6786f
3 changed files with 151 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,113 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout
|
||||
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_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 "Pocket" 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>
|
|
@ -486,4 +486,5 @@
|
|||
<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">Remove</string>
|
||||
<string name="user_name_password_placeholder">user_name Password</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue