From 50aea621ba4de844cf6eee077d1f5b14d0247f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 31 Jul 2014 21:51:35 +0200 Subject: [PATCH] Fix animations in create key --- .../keychain/ui/CreateKeyActivity.java | 30 ++++++++-------- .../keychain/ui/CreateKeyFinalFragment.java | 8 +---- .../keychain/ui/CreateKeyInputFragment.java | 2 +- .../res/layout/create_key_final_fragment.xml | 36 ++++++------------- OpenKeychain/src/main/res/values/strings.xml | 2 ++ 5 files changed, 31 insertions(+), 47 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyActivity.java index 569ae82f0..534ac5811 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyActivity.java @@ -29,9 +29,9 @@ public class CreateKeyActivity extends ActionBarActivity { public static final String EXTRA_NAME = "name"; public static final String EXTRA_EMAIL = "email"; - public static final int ANIM_NO = 0; - public static final int ANIM_TO_RIGHT = 1; - public static final int ANIM_TO_LEFT = 2; + public static final int FRAG_ACTION_START = 0; + public static final int FRAG_ACTION_TO_RIGHT = 1; + public static final int FRAG_ACTION_TO_LEFT = 2; @Override public void onCreate(Bundle savedInstanceState) { @@ -45,10 +45,10 @@ public class CreateKeyActivity extends ActionBarActivity { getIntent().getStringExtra(EXTRA_NAME), getIntent().getStringExtra(EXTRA_EMAIL) ); - loadFragment(null, frag, ANIM_NO); + loadFragment(null, frag, FRAG_ACTION_START); } - public void loadFragment(Bundle savedInstanceState, Fragment fragment, int animation) { + public void loadFragment(Bundle savedInstanceState, Fragment fragment, int action) { // However, if we're being restored from a previous state, // then we don't need to do anything and should return or else // we could end up with overlapping fragments. @@ -60,22 +60,24 @@ public class CreateKeyActivity extends ActionBarActivity { // NOTE: We use commitAllowingStateLoss() to prevent weird crashes! FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); - switch (animation) { - case ANIM_NO: + switch (action) { + case FRAG_ACTION_START: transaction.setCustomAnimations(0, 0); + transaction.replace(R.id.create_key_fragment_container, fragment) + .commitAllowingStateLoss(); break; - case ANIM_TO_LEFT: - transaction.setCustomAnimations(R.anim.frag_slide_in_from_left, R.anim.frag_slide_out_to_right); + case FRAG_ACTION_TO_LEFT: + getSupportFragmentManager().popBackStackImmediate(); break; - case ANIM_TO_RIGHT: - transaction.setCustomAnimations(R.anim.frag_slide_out_to_left, R.anim.frag_slide_in_from_right, + case FRAG_ACTION_TO_RIGHT: + transaction.setCustomAnimations(R.anim.frag_slide_in_from_right, R.anim.frag_slide_out_to_left, R.anim.frag_slide_in_from_left, R.anim.frag_slide_out_to_right); - transaction.addToBackStack("back"); + transaction.addToBackStack(null); + transaction.replace(R.id.create_key_fragment_container, fragment) + .commitAllowingStateLoss(); break; } - transaction.replace(R.id.create_key_fragment_container, fragment) - .commitAllowingStateLoss(); // do it immediately! getSupportFragmentManager().executePendingTransactions(); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java index c2c983b95..b64480087 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java @@ -20,11 +20,8 @@ package org.sufficientlysecure.keychain.ui; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; -import android.database.ContentObserver; import android.net.Uri; import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; import android.os.Message; import android.os.Messenger; import android.support.v4.app.Fragment; @@ -32,7 +29,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; -import android.widget.Spinner; import android.widget.TextView; import org.spongycastle.bcpg.sig.KeyFlags; @@ -110,9 +106,7 @@ public class CreateKeyFinalFragment extends Fragment { mBackButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - CreateKeyInputFragment frag = - CreateKeyInputFragment.newInstance(mName, mEmail); - mCreateKeyActivity.loadFragment(null, frag, CreateKeyActivity.ANIM_TO_LEFT); + mCreateKeyActivity.loadFragment(null, null, CreateKeyActivity.FRAG_ACTION_TO_LEFT); } }); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyInputFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyInputFragment.java index a1fdc09cc..ef5a3b145 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyInputFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyInputFragment.java @@ -161,7 +161,7 @@ public class CreateKeyInputFragment extends Fragment { ); hideKeyboard(); - mCreateKeyActivity.loadFragment(null, frag, CreateKeyActivity.ANIM_TO_RIGHT); + mCreateKeyActivity.loadFragment(null, frag, CreateKeyActivity.FRAG_ACTION_TO_RIGHT); } } diff --git a/OpenKeychain/src/main/res/layout/create_key_final_fragment.xml b/OpenKeychain/src/main/res/layout/create_key_final_fragment.xml index 74231142a..64b3621a4 100644 --- a/OpenKeychain/src/main/res/layout/create_key_final_fragment.xml +++ b/OpenKeychain/src/main/res/layout/create_key_final_fragment.xml @@ -20,14 +20,14 @@ android:layout_height="wrap_content" android:paddingTop="16dp" android:paddingBottom="8dp" - android:text="You entered the following credentials:" + android:text="@string/create_key_final_text" android:textAppearance="?android:attr/textAppearanceMedium" /> @@ -44,7 +44,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="2dp" - android:text="Email" + android:text="@string/label_email" android:textColor="@color/tertiary_text_light" android:textAppearance="?android:attr/textAppearanceSmall" /> @@ -76,30 +76,16 @@ android:layout_height="1dip" android:background="?android:attr/listDivider" /> - - - - - - - + android:text="@string/create_key_final_robot_text" + android:textColor="@color/android_green_dark" + android:textAppearance="?android:attr/textAppearanceMedium" + android:drawableLeft="@drawable/create_key_robot" + android:drawablePadding="8dp" /> @@ -123,7 +109,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" - android:text="back" + android:text="@string/btn_back" android:minHeight="?android:attr/listPreferredItemHeight" android:gravity="center_vertical" android:clickable="true" diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 0cffdd28a..bcd4d3bbc 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -508,6 +508,8 @@ Upload key to keyserver This field is required Passphrases do not match + You entered the following credentials: + Creating a key may take a while, have a cup of coffee in the meantime…\n(3 subkeys, RSA, 4096 bit) This key has been revoked!