Add AnimatedTabLayout library to project and use it in the SettingsActivity, the library still needs some improvements to use it correctly on the MainActivity (Board)

This commit is contained in:
Severiano Jaramillo 2018-06-20 17:25:29 -05:00
parent cea9e8faeb
commit c19839a921
5 changed files with 35 additions and 73 deletions

View file

@ -63,6 +63,7 @@ dependencies {
implementation 'com.github.bilthon:graphenej:0.4.6' implementation 'com.github.bilthon:graphenej:0.4.6'
implementation 'com.google.zxing:core:3.3.1' implementation 'com.google.zxing:core:3.3.1'
implementation 'me.dm7.barcodescanner:zxing:1.9.8' implementation 'me.dm7.barcodescanner:zxing:1.9.8'
implementation 'com.github.sjaramillo10:AnimatedTabLayout:v1.0.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.5.0' implementation 'com.squareup.okhttp3:logging-interceptor:3.5.0'
implementation 'de.hdodenhof:circleimageview:2.2.0' implementation 'de.hdodenhof:circleimageview:2.2.0'

View file

@ -5,15 +5,11 @@ import android.arch.lifecycle.ViewModelProviders;
import android.content.Context; import android.content.Context;
import android.content.ContextWrapper; import android.content.ContextWrapper;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.FileObserver;
import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.TabLayout; import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
@ -30,9 +26,9 @@ import android.view.View;
import android.view.animation.LinearInterpolator; import android.view.animation.LinearInterpolator;
import android.widget.ImageView; import android.widget.ImageView;
import com.sjaramillo10.animatedtablayout.AnimatedTabLayout;
import java.io.File; import java.io.File;
import java.util.List;
import java.util.Locale;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
@ -53,6 +49,9 @@ import cy.agorise.crystalwallet.viewmodels.CryptoNetBalanceListViewModel;
public class BoardActivity extends AppCompatActivity { public class BoardActivity extends AppCompatActivity {
@BindView(R.id.tabLayout)
public TabLayout tabLayout;
@BindView(R.id.pager) @BindView(R.id.pager)
public ViewPager mPager; public ViewPager mPager;
@ -123,11 +122,7 @@ public class BoardActivity extends AppCompatActivity {
boardAdapter = new BoardPagerAdapter(getSupportFragmentManager()); boardAdapter = new BoardPagerAdapter(getSupportFragmentManager());
mPager.setAdapter(boardAdapter); mPager.setAdapter(boardAdapter);
tabLayout.setupWithViewPager(mPager);
TabLayout tabLayout = findViewById(R.id.tabs);
mPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mPager));
fabReceive.setOnClickListener(new View.OnClickListener() { fabReceive.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -294,6 +289,9 @@ public class BoardActivity extends AppCompatActivity {
super(fm); super(fm);
} }
// Titles of the tabs
int[] tabTitles = {R.string.balances, R.string.transactions, R.string.contacts};
@Override @Override
public Fragment getItem(int position) { public Fragment getItem(int position) {
switch (position){ switch (position){
@ -309,6 +307,11 @@ public class BoardActivity extends AppCompatActivity {
return null; //new OnConstructionFragment(); return null; //new OnConstructionFragment();
} }
@Override
public CharSequence getPageTitle(int position) {
return getString(tabTitles[position]);
}
@Override @Override
public int getCount() { public int getCount() {
return 3; return 3;

View file

@ -2,7 +2,6 @@ package cy.agorise.crystalwallet.activities;
import android.media.MediaPlayer; import android.media.MediaPlayer;
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.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter; import android.support.v4.app.FragmentStatePagerAdapter;
@ -14,15 +13,13 @@ import android.view.SurfaceView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.sjaramillo10.animatedtablayout.AnimatedTabLayout;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import cy.agorise.crystalwallet.BuildConfig;
import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.application.CrystalSecurityMonitor;
import cy.agorise.crystalwallet.fragments.AccountsSettingsFragment;
import cy.agorise.crystalwallet.fragments.BackupsSettingsFragment; import cy.agorise.crystalwallet.fragments.BackupsSettingsFragment;
import cy.agorise.crystalwallet.fragments.BalanceFragment;
import cy.agorise.crystalwallet.fragments.GeneralSettingsFragment; import cy.agorise.crystalwallet.fragments.GeneralSettingsFragment;
import cy.agorise.crystalwallet.fragments.SecuritySettingsFragment; import cy.agorise.crystalwallet.fragments.SecuritySettingsFragment;
@ -36,6 +33,9 @@ public class SettingsActivity extends AppCompatActivity{
@BindView(R.id.ivGoBack) @BindView(R.id.ivGoBack)
public ImageView ivGoBack; public ImageView ivGoBack;
@BindView(R.id.tabLayout)
public AnimatedTabLayout tabLayout;
@BindView(R.id.pager) @BindView(R.id.pager)
public ViewPager mPager; public ViewPager mPager;
@ -80,11 +80,7 @@ public class SettingsActivity extends AppCompatActivity{
settingsPagerAdapter = new SettingsPagerAdapter(getSupportFragmentManager()); settingsPagerAdapter = new SettingsPagerAdapter(getSupportFragmentManager());
mPager.setAdapter(settingsPagerAdapter); mPager.setAdapter(settingsPagerAdapter);
tabLayout.setupWithViewPager(mPager);
TabLayout tabLayout = findViewById(R.id.tabs);
mPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mPager));
} }
private class SettingsPagerAdapter extends FragmentStatePagerAdapter { private class SettingsPagerAdapter extends FragmentStatePagerAdapter {
@ -92,6 +88,9 @@ public class SettingsActivity extends AppCompatActivity{
super(fm); super(fm);
} }
int[] tabTitles = {R.string.general, R.string.security, R.string.backups,
R.string.accounts};
@Override @Override
public Fragment getItem(int position) { public Fragment getItem(int position) {
switch (position){ switch (position){
@ -109,6 +108,11 @@ public class SettingsActivity extends AppCompatActivity{
return null; //new OnConstructionFragment(); return null; //new OnConstructionFragment();
} }
@Override
public CharSequence getPageTitle(int position) {
return getString(tabTitles[position]);
}
@Override @Override
public int getCount() { public int getCount() {
return 3; return 3;

View file

@ -79,39 +79,13 @@
</android.support.v7.widget.Toolbar> </android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout <com.sjaramillo10.animatedtablayout.AnimatedTabLayout
android:id="@+id/tabs" android:id="@+id/tabLayout"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:animateLayoutChanges="true"> android:animateLayoutChanges="true"
app:tabMode="fixed" />
<android.support.design.widget.TabItem
android:id="@+id/tabItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/general" />
<android.support.design.widget.TabItem
android:id="@+id/tabItem2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/security" />
<android.support.design.widget.TabItem
android:id="@+id/tabItem3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/backups" />
<!--<android.support.design.widget.TabItem
android:id="@+id/tabItem4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/accounts"
android:visibility="gone" />-->
</android.support.design.widget.TabLayout>
</RelativeLayout> </RelativeLayout>

View file

@ -97,32 +97,12 @@
</android.support.v7.widget.Toolbar> </android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout <android.support.design.widget.TabLayout
android:id="@+id/tabs" android:id="@+id/tabLayout"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_collapseMode="pin" app:layout_collapseMode="pin"
android:animateLayoutChanges="true"> android:animateLayoutChanges="true" />
<android.support.design.widget.TabItem
android:id="@+id/tabItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/balances" />
<android.support.design.widget.TabItem
android:id="@+id/tabItem2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/transactions" />
<android.support.design.widget.TabItem
android:id="@+id/tabItem3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/contacts" />
</android.support.design.widget.TabLayout>
</android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.CollapsingToolbarLayout>