From c19839a921c5db98affc7cb3b6d20eea8bcdb734 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Wed, 20 Jun 2018 17:25:29 -0500 Subject: [PATCH 1/3] 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) --- app/build.gradle | 1 + .../activities/BoardActivity.java | 25 ++++++++------ .../activities/SettingsActivity.java | 24 +++++++------ app/src/main/res/layout/activity_settings.xml | 34 +++---------------- app/src/main/res/layout/board.xml | 24 ++----------- 5 files changed, 35 insertions(+), 73 deletions(-) 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" /> From 17b0124946d0ec51408fef503b2cb2d7484cf2f6 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Wed, 20 Jun 2018 19:41:31 -0500 Subject: [PATCH 2/3] Update AnimatedTabLayout library and set Settings tab bold text --- app/build.gradle | 2 +- app/src/main/res/layout/activity_settings.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 8610a7d..aab91fa 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -63,7 +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.github.sjaramillo10:AnimatedTabLayout:1.0.3' implementation 'com.squareup.okhttp3:logging-interceptor:3.5.0' implementation 'de.hdodenhof:circleimageview:2.2.0' diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 1ee7d43..1880aea 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -85,6 +85,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:animateLayoutChanges="true" + app:tabBoldText="true" app:tabMode="fixed" /> From 2fef7769ae21b8c2869ead744ec959a482e6ce33 Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Wed, 20 Jun 2018 19:53:47 -0500 Subject: [PATCH 3/3] Improve Settings toolbar layout --- app/src/main/res/drawable/ic_arrow_back.xml | 2 +- app/src/main/res/drawable/ic_info_outline.xml | 2 +- app/src/main/res/layout/activity_settings.xml | 2 +- app/src/main/res/values/colors.xml | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/drawable/ic_arrow_back.xml b/app/src/main/res/drawable/ic_arrow_back.xml index f6c7026..9b2ab84 100644 --- a/app/src/main/res/drawable/ic_arrow_back.xml +++ b/app/src/main/res/drawable/ic_arrow_back.xml @@ -4,6 +4,6 @@ android:viewportWidth="24.0" android:viewportHeight="24.0"> diff --git a/app/src/main/res/drawable/ic_info_outline.xml b/app/src/main/res/drawable/ic_info_outline.xml index 075d9be..a1ec6ce 100644 --- a/app/src/main/res/drawable/ic_info_outline.xml +++ b/app/src/main/res/drawable/ic_info_outline.xml @@ -4,6 +4,6 @@ android:viewportWidth="24.0" android:viewportHeight="24.0"> diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 1880aea..e4161e6 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -58,7 +58,7 @@ android:layout_marginStart="8dp" android:text="@string/settings2" android:textStyle="bold" - android:textColor="@color/gray" + android:textColor="@color/semiTransparentWhite" android:textSize="18sp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toTopOf="parent" diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 38af09f..02ff5ff 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -10,6 +10,7 @@ #f0006b #00ffffff #330099d6 + #8fff #147b00