Added new animation

This commit is contained in:
Moez Bhatti
2016-01-10 02:52:49 -05:00
parent f049bdf397
commit 828c2ae396
20 changed files with 133 additions and 41 deletions
@@ -14,6 +14,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.PorterDuff;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
@@ -22,6 +23,7 @@ import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.provider.MediaStore;
import android.support.v4.content.ContextCompat;
import android.text.InputType;
import android.text.TextUtils;
import android.util.AttributeSet;
@@ -104,8 +106,7 @@ public class ComposeView extends LinearLayout implements View.OnClickListener {
private FrameLayout mButton;
private DonutProgress mProgress;
private ImageView mButtonBackground;
private ImageView mButtonBar1;
private ImageView mButtonBar2;
private ImageView mComposeIcon;
private ImageButton mAttach;
private ImageButton mCamera;
private ImageButton mDelay;
@@ -164,8 +165,7 @@ public class ComposeView extends LinearLayout implements View.OnClickListener {
mButton = (FrameLayout) findViewById(R.id.compose_button);
mProgress = (DonutProgress) findViewById(R.id.progress);
mButtonBackground = (ImageView) findViewById(R.id.compose_button_background);
mButtonBar1 = (ImageView) findViewById(R.id.compose_button_bar_1);
mButtonBar2 = (ImageView) findViewById(R.id.compose_button_bar_2);
mComposeIcon = (ImageView) findViewById(R.id.compose_icon);
mAttachmentPanel = findViewById(R.id.attachment_panel);
mAttach = (ImageButton) findViewById(R.id.attach);
mCamera = (ImageButton) findViewById(R.id.camera);
@@ -183,8 +183,7 @@ public class ComposeView extends LinearLayout implements View.OnClickListener {
LiveViewManager.registerView(QKPreference.THEME, this, key -> {
mButtonBackground.setColorFilter(ThemeManager.getColor(), PorterDuff.Mode.SRC_ATOP);
mButtonBar1.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
mButtonBar2.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
mComposeIcon.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
mAttachmentPanel.setBackgroundColor(ThemeManager.getColor());
mAttach.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
mCamera.setColorFilter(ThemeManager.getTextOnColorPrimary(), PorterDuff.Mode.SRC_ATOP);
@@ -361,30 +360,27 @@ public class ComposeView extends LinearLayout implements View.OnClickListener {
private void updateButtonState(SendButtonState buttonState) {
if (mButtonState != buttonState) {
// Check if we need to switch animations
AnimationDrawable animation = null;
if (buttonState == SendButtonState.SEND) {
animation = (AnimationDrawable) ContextCompat.getDrawable(mContext, R.drawable.plus_to_arrow);
} else if (mButtonState == SendButtonState.SEND) {
animation = (AnimationDrawable) ContextCompat.getDrawable(mContext, R.drawable.arrow_to_plus);
}
if (animation != null) {
mComposeIcon.setImageDrawable(animation);
animation.start();
}
// Handle any necessary rotation
float rotation = mComposeIcon.getRotation();
float target = buttonState == SendButtonState.ATTACH || buttonState == SendButtonState.SEND ? 0 : 45;
ObjectAnimator.ofFloat(mComposeIcon, "rotation", rotation, target)
.setDuration(ANIMATION_DURATION)
.start();
mButtonState = buttonState;
float translation = Units.dpToPx(mContext, 14) / 3;
float barRotation1 = mButtonBar1.getRotation();
float barTranslation1 = mButtonBar1.getTranslationY();
float barRotation2 = mButtonBar2.getRotation();
float barTranslation2 = mButtonBar2.getTranslationY();
float barRotationTarget1 = mButtonState == SendButtonState.ATTACH ? 0 : 225;
float barTranslationTarget1 = mButtonState == SendButtonState.SEND ? -translation : 0;
float barRotationTarget2 = mButtonState == SendButtonState.ATTACH ? 90 : 135;
float barTranslationTarget2 = mButtonState == SendButtonState.SEND ? translation : 0;
ObjectAnimator.ofFloat(mButtonBar1, "rotation", barRotation1, barRotationTarget1)
.setDuration(ANIMATION_DURATION)
.start();
ObjectAnimator.ofFloat(mButtonBar2, "rotation", barRotation2, barRotationTarget2)
.setDuration(ANIMATION_DURATION)
.start();
ObjectAnimator.ofFloat(mButtonBar1, "translationY", barTranslation1, barTranslationTarget1)
.setDuration(ANIMATION_DURATION)
.start();
ObjectAnimator.ofFloat(mButtonBar2, "translationY", barTranslation2, barTranslationTarget2)
.setDuration(ANIMATION_DURATION)
.start();
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item
android:drawable="@drawable/plus_to_arrow_15"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_14"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_13"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_12"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_11"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_10"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_09"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_08"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_07"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_06"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_05"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_04"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_03"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_02"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_01"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_00"
android:duration="10" />
</animation-list>
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item
android:drawable="@drawable/plus_to_arrow_00"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_01"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_02"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_03"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_04"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_05"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_06"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_07"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_08"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_09"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_10"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_11"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_12"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_13"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_14"
android:duration="10" />
<item
android:drawable="@drawable/plus_to_arrow_15"
android:duration="10" />
</animation-list>
+4 -12
View File
@@ -92,19 +92,11 @@
android:src="@drawable/send_background" />
<ImageView
android:id="@+id/compose_button_bar_1"
android:layout_width="14dp"
android:layout_height="2dp"
android:id="@+id/compose_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:src="@color/white_pure" />
<ImageView
android:id="@+id/compose_button_bar_2"
android:layout_width="14dp"
android:layout_height="2dp"
android:layout_gravity="center"
android:rotation="90"
android:src="@color/white_pure" />
android:src="@drawable/plus_to_arrow" />
<com.github.lzyzsd.circleprogress.DonutProgress
android:id="@+id/progress"