Removed Toolbar animation in all the other activities it was being used and changed to use the GIF version instead. It provides a much cleaner and safer implementation that works fine on all tested devices (Android L, M, O & P).

This commit is contained in:
Severiano Jaramillo 2018-10-25 13:40:45 -05:00
parent 36d97e8166
commit 4cd304d732
11 changed files with 48 additions and 255 deletions

View file

@ -122,8 +122,8 @@ dependencies {
kapt "android.arch.persistence.room:compiler:1.1.0" kapt "android.arch.persistence.room:compiler:1.1.0"
// Glide dependencies // Glide dependencies
implementation 'com.github.bumptech.glide:glide:4.7.1' implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1' annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
debugImplementation 'com.amitshekhar.android:debug-db:1.0.4' debugImplementation 'com.amitshekhar.android:debug-db:1.0.4'
} }

View file

@ -14,6 +14,9 @@ import android.view.SurfaceView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
@ -37,18 +40,11 @@ public class AccountSettingsActivity extends AppCompatActivity{
public SettingsPagerAdapter settingsPagerAdapter; public SettingsPagerAdapter settingsPagerAdapter;
@BindView(R.id.surface_view)
public SurfaceView mSurfaceView;
@BindView(R.id.tvBuildVersion) @BindView(R.id.tvBuildVersion)
public TextView tvBuildVersion; public TextView tvBuildVersion;
/* @BindView(R.id.ivAppBarAnimation)
* For the window animation ImageView ivAppBarAnimation;
* */
private MediaPlayer mediaPlayer;
@Override @Override
@ -60,29 +56,11 @@ public class AccountSettingsActivity extends AppCompatActivity{
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
// Appbar animation // Sets AppBar animation
mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() { Glide.with(this)
@Override .load(R.drawable.appbar_background)
public void surfaceCreated(SurfaceHolder surfaceHolder) { .apply(new RequestOptions().centerCrop())
//Log.d(TAG,"surfaceCreated"); .into(ivAppBarAnimation);
mediaPlayer = MediaPlayer.create(AccountSettingsActivity.this, R.raw.appbar_background);
mediaPlayer.setDisplay(mSurfaceView.getHolder());
mediaPlayer.setLooping(true);
mediaPlayer.start();
}
@Override
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {
//Log.d(TAG,"surfaceChanged");
}
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
//Log.d(TAG,"surfaceDestroyed");
mediaPlayer.stop();
mediaPlayer.release();
}
});
settingsPagerAdapter = new SettingsPagerAdapter(getSupportFragmentManager()); settingsPagerAdapter = new SettingsPagerAdapter(getSupportFragmentManager());
mPager.setAdapter(settingsPagerAdapter); mPager.setAdapter(settingsPagerAdapter);
@ -93,19 +71,6 @@ public class AccountSettingsActivity extends AppCompatActivity{
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mPager)); tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mPager));
} }
@Override
protected void onDestroy() {
super.onDestroy();
//Release the media player
if(mediaPlayer!=null){
mediaPlayer.release();
mediaPlayer = null;
}
}
private class SettingsPagerAdapter extends FragmentStatePagerAdapter { private class SettingsPagerAdapter extends FragmentStatePagerAdapter {
SettingsPagerAdapter(FragmentManager fm) { SettingsPagerAdapter(FragmentManager fm) {
super(fm); super(fm);

View file

@ -8,9 +8,6 @@ import android.content.Intent;
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.graphics.Color;
import android.graphics.Typeface;
import android.media.MediaPlayer;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.TabLayout; import android.support.design.widget.TabLayout;
@ -20,18 +17,10 @@ import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.util.Pair; import android.util.Pair;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator; import android.view.animation.LinearInterpolator;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
@ -48,7 +37,6 @@ import cy.agorise.crystalwallet.fragments.MerchantsFragment;
import cy.agorise.crystalwallet.fragments.ReceiveTransactionFragment; import cy.agorise.crystalwallet.fragments.ReceiveTransactionFragment;
import cy.agorise.crystalwallet.fragments.SendTransactionFragment; import cy.agorise.crystalwallet.fragments.SendTransactionFragment;
import cy.agorise.crystalwallet.fragments.TransactionsFragment; import cy.agorise.crystalwallet.fragments.TransactionsFragment;
import cy.agorise.crystalwallet.views.natives.GIFView;
import de.hdodenhof.circleimageview.CircleImageView; import de.hdodenhof.circleimageview.CircleImageView;
import cy.agorise.crystalwallet.viewmodels.CryptoNetBalanceListViewModel; import cy.agorise.crystalwallet.viewmodels.CryptoNetBalanceListViewModel;
@ -73,8 +61,8 @@ public class BoardActivity extends CustomActivity {
@BindView(R.id.fabAddContact) @BindView(R.id.fabAddContact)
public FloatingActionButton fabAddContact; public FloatingActionButton fabAddContact;
@BindView(R.id.imagevieGIF) @BindView(R.id.ivAppBarAnimation)
public GIFView imagevieGIF; ImageView ivAppBarAnimation;
public BoardPagerAdapter boardAdapter; public BoardPagerAdapter boardAdapter;
@ -84,9 +72,6 @@ public class BoardActivity extends CustomActivity {
*/ */
long cryptoNetAccountId; long cryptoNetAccountId;
@BindView(R.id.surface_view)
public SurfaceView mSurfaceView;
@BindView(R.id.toolbar_user_img) @BindView(R.id.toolbar_user_img)
public CircleImageView userImage; public CircleImageView userImage;
@ -98,14 +83,6 @@ public class BoardActivity extends CustomActivity {
File photoDirectory; File photoDirectory;
/*
* For the window animation
* */
private MediaPlayer mediaPlayer;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -118,39 +95,11 @@ public class BoardActivity extends CustomActivity {
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
/* // Sets AppBar animation
* Set the bubbles animation Glide.with(this)
* */ .load(R.drawable.appbar_background)
//imagevieGIF.centerCrop(); .apply(new RequestOptions().centerCrop())
//imagevieGIF.load(R.raw.burbujas); .into(ivAppBarAnimation);
/*
* Listener tabLayout to resalt text when clicked
* */
// Appbar animation
mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {
//Log.d(TAG,"surfaceCreated");
mediaPlayer = MediaPlayer.create(BoardActivity.this, R.raw.appbar_background);
mediaPlayer.setDisplay(mSurfaceView.getHolder());
mediaPlayer.setLooping(true);
mediaPlayer.start();
}
@Override
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {
//Log.d(TAG,"surfaceChanged");
}
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
//Log.d(TAG,"surfaceDestroyed");
mediaPlayer.stop();
mediaPlayer.release();
}
});
boardAdapter = new BoardPagerAdapter(getSupportFragmentManager()); boardAdapter = new BoardPagerAdapter(getSupportFragmentManager());
mPager.setAdapter(boardAdapter); mPager.setAdapter(boardAdapter);
@ -236,17 +185,6 @@ public class BoardActivity extends CustomActivity {
loadUserImage(); loadUserImage();
} }
@Override
protected void onDestroy() {
super.onDestroy();
//Release the media player
if(mediaPlayer!=null){
mediaPlayer.release();
mediaPlayer = null;
}
}
public void loadUserImage(){ public void loadUserImage(){
//Search for a existing photo //Search for a existing photo
File photoFile = new File(photoDirectory + File.separator + "photo.png"); File photoFile = new File(photoDirectory + File.separator + "photo.png");

View file

@ -18,6 +18,9 @@ import android.view.SurfaceView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
@ -45,8 +48,6 @@ public class CryptoNetAccountSettingsActivity extends AppCompatActivity{
public SettingsPagerAdapter settingsPagerAdapter; public SettingsPagerAdapter settingsPagerAdapter;
@BindView(R.id.surface_view)
public SurfaceView mSurfaceView;
@BindView(R.id.tvBuildVersion) @BindView(R.id.tvBuildVersion)
public TextView tvBuildVersion; public TextView tvBuildVersion;
@ -56,13 +57,8 @@ public class CryptoNetAccountSettingsActivity extends AppCompatActivity{
private CryptoNetAccount cryptoNetAccount; private CryptoNetAccount cryptoNetAccount;
/* @BindView(R.id.ivAppBarAnimation)
* For the window animation ImageView ivAppBarAnimation;
* */
private MediaPlayer mediaPlayer;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -101,27 +97,11 @@ public class CryptoNetAccountSettingsActivity extends AppCompatActivity{
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
// Appbar animation // Sets AppBar animation
mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() { Glide.with(this)
@Override .load(R.drawable.appbar_background)
public void surfaceCreated(SurfaceHolder surfaceHolder) { .apply(new RequestOptions().centerCrop())
//Log.d(TAG,"surfaceCreated"); .into(ivAppBarAnimation);
mediaPlayer = MediaPlayer.create(CryptoNetAccountSettingsActivity.this, R.raw.appbar_background);
mediaPlayer.setDisplay(mSurfaceView.getHolder());
mediaPlayer.setLooping(true);
mediaPlayer.start();
}
@Override
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {
//Log.d(TAG,"surfaceChanged");
}
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
//Log.d(TAG,"surfaceDestroyed");
}
});
} else { } else {
@ -129,19 +109,6 @@ public class CryptoNetAccountSettingsActivity extends AppCompatActivity{
} }
} }
@Override
protected void onDestroy() {
super.onDestroy();
//Release the media player
if(mediaPlayer!=null){
mediaPlayer.release();
mediaPlayer = null;
}
}
private class SettingsPagerAdapter extends FragmentStatePagerAdapter { private class SettingsPagerAdapter extends FragmentStatePagerAdapter {
SettingsPagerAdapter(FragmentManager fm) { SettingsPagerAdapter(FragmentManager fm) {
super(fm); super(fm);

View file

@ -14,6 +14,8 @@ import android.view.SurfaceView;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.sjaramillo10.animatedtablayout.AnimatedTabLayout; import com.sjaramillo10.animatedtablayout.AnimatedTabLayout;
import butterknife.BindView; import butterknife.BindView;
@ -42,20 +44,13 @@ public class SettingsActivity extends AppCompatActivity{
public SettingsPagerAdapter settingsPagerAdapter; public SettingsPagerAdapter settingsPagerAdapter;
@BindView(R.id.surface_view)
public SurfaceView mSurfaceView;
@BindView(R.id.tvBuildVersion) @BindView(R.id.tvBuildVersion)
public TextView tvBuildVersion; public TextView tvBuildVersion;
private SecuritySettingsFragment securitySettingsFragment; private SecuritySettingsFragment securitySettingsFragment;
/* @BindView(R.id.ivAppBarAnimation)
* For the window animation ImageView ivAppBarAnimation;
* */
private MediaPlayer mediaPlayer;
@Override @Override
@ -67,29 +62,11 @@ public class SettingsActivity extends AppCompatActivity{
Toolbar toolbar = findViewById(R.id.toolbar); Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
// Appbar animation // Sets AppBar animation
mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() { Glide.with(this)
@Override .load(R.drawable.appbar_background)
public void surfaceCreated(SurfaceHolder surfaceHolder) { .apply(new RequestOptions().centerCrop())
//Log.d(TAG,"surfaceCreated"); .into(ivAppBarAnimation);
mediaPlayer = MediaPlayer.create(SettingsActivity.this, R.raw.appbar_background);
mediaPlayer.setDisplay(mSurfaceView.getHolder());
mediaPlayer.setLooping(true);
mediaPlayer.start();
}
@Override
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {
//Log.d(TAG,"surfaceChanged");
}
@Override
public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
//Log.d(TAG,"surfaceDestroyed");
mediaPlayer.stop();
mediaPlayer.release();
}
});
settingsPagerAdapter = new SettingsPagerAdapter(getSupportFragmentManager()); settingsPagerAdapter = new SettingsPagerAdapter(getSupportFragmentManager());
mPager.setAdapter(settingsPagerAdapter); mPager.setAdapter(settingsPagerAdapter);
@ -133,17 +110,6 @@ public class SettingsActivity extends AppCompatActivity{
} }
} }
@Override
protected void onDestroy() {
super.onDestroy();
//Release the media player
if(mediaPlayer != null){
mediaPlayer.release();
mediaPlayer = null;
}
}
@OnClick(R.id.ivGoBack) @OnClick(R.id.ivGoBack)
public void goBack(){ public void goBack(){
onBackPressed(); onBackPressed();

View file

@ -1,34 +0,0 @@
package cy.agorise.crystalwallet.views.natives
import android.content.Context
import android.net.Uri
import android.util.AttributeSet
import android.widget.VideoView
import cy.agorise.crystalwallet.R
import kotlinx.android.synthetic.main.empty_activity.*
/*
* Extensión for videoview
* */
class VideoExView(context: Context?, attrs: AttributeSet?) : VideoView(context, attrs) {
/*
* Set the path based on raw, this should be called first to set the video path
* */
fun setVideoRaw(rawID:Int){
val uriPath = "android.resource://" + context.packageName + "/" + R.raw.appbar_background
val uri = Uri.parse(uriPath)
this.setVideoURI(uri)
}
/*
* With this method the video play continues
* */
fun playContinius(){
start()
this.setOnCompletionListener {
start()
}
}
}

View file

@ -19,10 +19,10 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<SurfaceView <ImageView
android:id="@+id/surface_view" android:id="@+id/ivAppBarAnimation"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent" />
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -20,21 +20,19 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:background="@color/red"
app:contentScrim="@color/transparent" app:contentScrim="@color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed" app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="@+id/toolbar"> app:toolbarId="@+id/toolbar">
<SurfaceView <ImageView
android:id="@+id/surface_view" android:id="@+id/ivAppBarAnimation"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
<cy.agorise.crystalwallet.views.natives.GIFView <View
android:id="@+id/imagevieGIF"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
/> android:background="@color/colorPrimaryTransparent"/>
<android.support.v7.widget.Toolbar <android.support.v7.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"

View file

@ -19,10 +19,10 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<SurfaceView <ImageView
android:id="@+id/surface_view" android:id="@+id/ivAppBarAnimation"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent" />
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -10,11 +10,4 @@
android:layout_height="200px" android:layout_height="200px"
android:layout_centerInParent="true"/> android:layout_centerInParent="true"/>
<cy.agorise.crystalwallet.views.natives.VideoExView
android:layout_width="match_parent"
android:layout_height="200px"
android:layout_centerInParent="true"
android:visibility="gone"
android:id="@+id/video"/>
</RelativeLayout> </RelativeLayout>