SetupWizard: Move reveal finish animation up to activity

Change-Id: I983cfcfad3fcd9808442917bb8b4ae7f8a8d7c2b
This commit is contained in:
cretin45 2015-01-27 15:23:16 -08:00
parent c5e5df96b1
commit 031e58ebc4
4 changed files with 81 additions and 87 deletions

View File

@ -17,31 +17,15 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="@color/primary">
<FrameLayout android:id="@+id/page"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ImageView
android:id="@+id/brand_logo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/brand_finish"
android:scaleType="fitCenter"
android:padding="@dimen/content_margin_left"/>
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/primary">
<ImageView
android:id="@+id/brand_logo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/brand_finish"
android:scaleType="centerInside"/>
</LinearLayout>
<ImageView android:id="@+id/reveal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/reveal"
android:visibility="invisible"/>
</FrameLayout>
</LinearLayout>

View File

@ -14,19 +14,33 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true">
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true">
<FrameLayout android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
style="@style/PageContainer"/>
<LinearLayout android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true">
<include layout="@layout/button_bar" />
<FrameLayout android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
style="@style/PageContainer"/>
<include layout="@layout/button_bar" />
</LinearLayout>
<ImageView android:id="@+id/reveal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/reveal"
android:visibility="invisible"/>
</FrameLayout>
</LinearLayout>

View File

@ -16,17 +16,13 @@
package com.cyanogenmod.setupwizard.setup;
import com.cyanogenmod.setupwizard.R;
import com.cyanogenmod.setupwizard.ui.SetupPageFragment;
import android.animation.Animator;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.ViewAnimationUtils;
import com.cyanogenmod.setupwizard.R;
import com.cyanogenmod.setupwizard.ui.SetupPageFragment;
public class FinishPage extends SetupPage {
@ -63,7 +59,7 @@ public class FinishPage extends SetupPage {
@Override
public boolean doNextAction() {
mFinishFragment.animateOut(getCallbacks());
getCallbacks().onFinish();
return true;
}
@ -79,53 +75,14 @@ public class FinishPage extends SetupPage {
public static class FinishFragment extends SetupPageFragment {
private View mReveal;
private Handler mHandler;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mHandler = new Handler();
getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.primary));
}
@Override
protected void initializePage() {
mReveal = mRootView.findViewById(R.id.reveal);
}
private void animateOut(final SetupDataCallbacks callbacks) {
int cx = (mReveal.getLeft() + mReveal.getRight()) / 2;
int cy = (mReveal.getTop() + mReveal.getBottom()) / 2;
int finalRadius = Math.max(mReveal.getWidth(), mReveal.getHeight());
Animator anim =
ViewAnimationUtils.createCircularReveal(mReveal, cx, cy, 0, finalRadius);
anim.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
mReveal.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animator animation) {
mHandler.post(new Runnable() {
@Override
public void run() {
callbacks.onFinish();
}
});
}
@Override
public void onAnimationCancel(Animator animation) {}
@Override
public void onAnimationRepeat(Animator animation) {}
});
anim.start();
}
protected void initializePage() {}
@Override
protected int getLayoutResource() {

View File

@ -16,16 +16,19 @@
package com.cyanogenmod.setupwizard.ui;
import android.animation.Animator;
import android.app.Activity;
import android.app.AppGlobals;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.widget.Button;
import com.cyanogenmod.setupwizard.R;
@ -48,9 +51,12 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
private View mRootView;
private Button mNextButton;
private Button mPrevButton;
private View mReveal;
private AbstractSetupData mSetupData;
private final Handler mHandler = new Handler();
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.setup_main);
@ -63,6 +69,7 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
}
mNextButton = (Button) findViewById(R.id.next_button);
mPrevButton = (Button) findViewById(R.id.prev_button);
mReveal = findViewById(R.id.reveal);
mSetupData.registerListener(this);
mNextButton.setOnClickListener(new View.OnClickListener() {
@Override
@ -210,7 +217,39 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
@Override
public void onFinish() {
finishSetup();
animateOut();
}
private void animateOut() {
int cx = (mReveal.getLeft() + mReveal.getRight()) / 2;
int cy = (mReveal.getTop() + mReveal.getBottom()) / 2;
int finalRadius = Math.max(mReveal.getWidth(), mReveal.getHeight());
Animator anim =
ViewAnimationUtils.createCircularReveal(mReveal, cx, cy, 0, finalRadius);
anim.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
mReveal.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animator animation) {
mHandler.post(new Runnable() {
@Override
public void run() {
finishSetup();;
}
});
}
@Override
public void onAnimationCancel(Animator animation) {}
@Override
public void onAnimationRepeat(Animator animation) {}
});
anim.start();
}
private void handleWhisperPushRegistration() {