diff --git a/app/build.gradle b/app/build.gradle index 3715f33..8610a7d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -63,6 +63,7 @@ dependencies { implementation 'com.github.bilthon:graphenej:0.4.6' implementation 'com.google.zxing:core:3.3.1' 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 'de.hdodenhof:circleimageview:2.2.0' diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/BoardActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/BoardActivity.java index 1d366cd..c9f5a16 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/BoardActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/BoardActivity.java @@ -5,15 +5,11 @@ import android.arch.lifecycle.ViewModelProviders; import android.content.Context; import android.content.ContextWrapper; import android.content.Intent; -import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.media.MediaPlayer; -import android.net.Uri; import android.os.Bundle; -import android.os.FileObserver; -import android.support.annotation.Nullable; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; @@ -30,9 +26,9 @@ import android.view.View; import android.view.animation.LinearInterpolator; import android.widget.ImageView; +import com.sjaramillo10.animatedtablayout.AnimatedTabLayout; + import java.io.File; -import java.util.List; -import java.util.Locale; import butterknife.BindView; import butterknife.ButterKnife; @@ -53,6 +49,9 @@ import cy.agorise.crystalwallet.viewmodels.CryptoNetBalanceListViewModel; public class BoardActivity extends AppCompatActivity { + @BindView(R.id.tabLayout) + public TabLayout tabLayout; + @BindView(R.id.pager) public ViewPager mPager; @@ -123,11 +122,7 @@ public class BoardActivity extends AppCompatActivity { boardAdapter = new BoardPagerAdapter(getSupportFragmentManager()); mPager.setAdapter(boardAdapter); - - TabLayout tabLayout = findViewById(R.id.tabs); - - mPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); - tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mPager)); + tabLayout.setupWithViewPager(mPager); fabReceive.setOnClickListener(new View.OnClickListener() { @Override @@ -294,6 +289,9 @@ public class BoardActivity extends AppCompatActivity { super(fm); } + // Titles of the tabs + int[] tabTitles = {R.string.balances, R.string.transactions, R.string.contacts}; + @Override public Fragment getItem(int position) { switch (position){ @@ -309,6 +307,11 @@ public class BoardActivity extends AppCompatActivity { return null; //new OnConstructionFragment(); } + @Override + public CharSequence getPageTitle(int position) { + return getString(tabTitles[position]); + } + @Override public int getCount() { return 3; diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/SettingsActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/SettingsActivity.java index 26b74a8..24b6dae 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/SettingsActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/SettingsActivity.java @@ -2,7 +2,6 @@ package cy.agorise.crystalwallet.activities; import android.media.MediaPlayer; 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.FragmentStatePagerAdapter; @@ -14,15 +13,13 @@ import android.view.SurfaceView; import android.widget.ImageView; import android.widget.TextView; +import com.sjaramillo10.animatedtablayout.AnimatedTabLayout; + import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnClick; -import cy.agorise.crystalwallet.BuildConfig; 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.BalanceFragment; import cy.agorise.crystalwallet.fragments.GeneralSettingsFragment; import cy.agorise.crystalwallet.fragments.SecuritySettingsFragment; @@ -36,6 +33,9 @@ public class SettingsActivity extends AppCompatActivity{ @BindView(R.id.ivGoBack) public ImageView ivGoBack; + @BindView(R.id.tabLayout) + public AnimatedTabLayout tabLayout; + @BindView(R.id.pager) public ViewPager mPager; @@ -80,11 +80,7 @@ public class SettingsActivity extends AppCompatActivity{ settingsPagerAdapter = new SettingsPagerAdapter(getSupportFragmentManager()); mPager.setAdapter(settingsPagerAdapter); - - TabLayout tabLayout = findViewById(R.id.tabs); - - mPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); - tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mPager)); + tabLayout.setupWithViewPager(mPager); } private class SettingsPagerAdapter extends FragmentStatePagerAdapter { @@ -92,6 +88,9 @@ public class SettingsActivity extends AppCompatActivity{ super(fm); } + int[] tabTitles = {R.string.general, R.string.security, R.string.backups, + R.string.accounts}; + @Override public Fragment getItem(int position) { switch (position){ @@ -109,6 +108,11 @@ public class SettingsActivity extends AppCompatActivity{ return null; //new OnConstructionFragment(); } + @Override + public CharSequence getPageTitle(int position) { + return getString(tabTitles[position]); + } + @Override public int getCount() { return 3; diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 7b91bba..1ee7d43 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -79,39 +79,13 @@ - - - - - - - - - - - + android:animateLayoutChanges="true" + app:tabMode="fixed" /> diff --git a/app/src/main/res/layout/board.xml b/app/src/main/res/layout/board.xml index f9acfd1..19af46e 100644 --- a/app/src/main/res/layout/board.xml +++ b/app/src/main/res/layout/board.xml @@ -97,32 +97,12 @@ - - - - - - - - + android:animateLayoutChanges="true" />