Fix animations in create key

This commit is contained in:
Dominik Schürmann 2014-07-31 21:51:35 +02:00
parent b9694ae9c5
commit 50aea621ba
5 changed files with 31 additions and 47 deletions

View file

@ -29,9 +29,9 @@ public class CreateKeyActivity extends ActionBarActivity {
public static final String EXTRA_NAME = "name"; public static final String EXTRA_NAME = "name";
public static final String EXTRA_EMAIL = "email"; public static final String EXTRA_EMAIL = "email";
public static final int ANIM_NO = 0; public static final int FRAG_ACTION_START = 0;
public static final int ANIM_TO_RIGHT = 1; public static final int FRAG_ACTION_TO_RIGHT = 1;
public static final int ANIM_TO_LEFT = 2; public static final int FRAG_ACTION_TO_LEFT = 2;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -45,10 +45,10 @@ public class CreateKeyActivity extends ActionBarActivity {
getIntent().getStringExtra(EXTRA_NAME), getIntent().getStringExtra(EXTRA_NAME),
getIntent().getStringExtra(EXTRA_EMAIL) 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, // However, if we're being restored from a previous state,
// then we don't need to do anything and should return or else // then we don't need to do anything and should return or else
// we could end up with overlapping fragments. // we could end up with overlapping fragments.
@ -60,22 +60,24 @@ public class CreateKeyActivity extends ActionBarActivity {
// NOTE: We use commitAllowingStateLoss() to prevent weird crashes! // NOTE: We use commitAllowingStateLoss() to prevent weird crashes!
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
switch (animation) { switch (action) {
case ANIM_NO: case FRAG_ACTION_START:
transaction.setCustomAnimations(0, 0); transaction.setCustomAnimations(0, 0);
transaction.replace(R.id.create_key_fragment_container, fragment)
.commitAllowingStateLoss();
break; break;
case ANIM_TO_LEFT: case FRAG_ACTION_TO_LEFT:
transaction.setCustomAnimations(R.anim.frag_slide_in_from_left, R.anim.frag_slide_out_to_right); getSupportFragmentManager().popBackStackImmediate();
break; break;
case ANIM_TO_RIGHT: case FRAG_ACTION_TO_RIGHT:
transaction.setCustomAnimations(R.anim.frag_slide_out_to_left, R.anim.frag_slide_in_from_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); 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; break;
} }
transaction.replace(R.id.create_key_fragment_container, fragment)
.commitAllowingStateLoss();
// do it immediately! // do it immediately!
getSupportFragmentManager().executePendingTransactions(); getSupportFragmentManager().executePendingTransactions();
} }

View file

@ -20,11 +20,8 @@ package org.sufficientlysecure.keychain.ui;
import android.app.Activity; import android.app.Activity;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Intent; import android.content.Intent;
import android.database.ContentObserver;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message; import android.os.Message;
import android.os.Messenger; import android.os.Messenger;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
@ -32,7 +29,6 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import org.spongycastle.bcpg.sig.KeyFlags; import org.spongycastle.bcpg.sig.KeyFlags;
@ -110,9 +106,7 @@ public class CreateKeyFinalFragment extends Fragment {
mBackButton.setOnClickListener(new View.OnClickListener() { mBackButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
CreateKeyInputFragment frag = mCreateKeyActivity.loadFragment(null, null, CreateKeyActivity.FRAG_ACTION_TO_LEFT);
CreateKeyInputFragment.newInstance(mName, mEmail);
mCreateKeyActivity.loadFragment(null, frag, CreateKeyActivity.ANIM_TO_LEFT);
} }
}); });

View file

@ -161,7 +161,7 @@ public class CreateKeyInputFragment extends Fragment {
); );
hideKeyboard(); hideKeyboard();
mCreateKeyActivity.loadFragment(null, frag, CreateKeyActivity.ANIM_TO_RIGHT); mCreateKeyActivity.loadFragment(null, frag, CreateKeyActivity.FRAG_ACTION_TO_RIGHT);
} }
} }

View file

@ -20,14 +20,14 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingTop="16dp" android:paddingTop="16dp"
android:paddingBottom="8dp" android:paddingBottom="8dp"
android:text="You entered the following credentials:" android:text="@string/create_key_final_text"
android:textAppearance="?android:attr/textAppearanceMedium" /> android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="2dp" android:layout_marginBottom="2dp"
android:text="Name" android:text="@string/label_name"
android:textColor="@color/tertiary_text_light" android:textColor="@color/tertiary_text_light"
android:textAppearance="?android:attr/textAppearanceSmall" /> android:textAppearance="?android:attr/textAppearanceSmall" />
@ -44,7 +44,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="2dp" android:layout_marginBottom="2dp"
android:text="Email" android:text="@string/label_email"
android:textColor="@color/tertiary_text_light" android:textColor="@color/tertiary_text_light"
android:textAppearance="?android:attr/textAppearanceSmall" /> android:textAppearance="?android:attr/textAppearanceSmall" />
@ -76,30 +76,16 @@
android:layout_height="1dip" android:layout_height="1dip"
android:background="?android:attr/listDivider" /> android:background="?android:attr/listDivider" />
<LinearLayout <TextView
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:orientation="horizontal"> android:text="@string/create_key_final_robot_text"
android:textColor="@color/android_green_dark"
<ImageView android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content" android:drawableLeft="@drawable/create_key_robot"
android:layout_height="wrap_content" android:drawablePadding="8dp" />
android:id="@+id/imageView"
android:src="@drawable/create_key_robot"
android:layout_gravity="center_vertical" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:text="Creating a key may take a while, have a cup of coffee in the meantime…\n(3 subkeys, RSA, 4096 bit)"
android:textColor="@color/android_green_dark"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/textView" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
@ -123,7 +109,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="back" android:text="@string/btn_back"
android:minHeight="?android:attr/listPreferredItemHeight" android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical" android:gravity="center_vertical"
android:clickable="true" android:clickable="true"

View file

@ -508,6 +508,8 @@
<string name="create_key_upload">Upload key to keyserver</string> <string name="create_key_upload">Upload key to keyserver</string>
<string name="create_key_empty">This field is required</string> <string name="create_key_empty">This field is required</string>
<string name="create_key_passphrases_not_equal">Passphrases do not match</string> <string name="create_key_passphrases_not_equal">Passphrases do not match</string>
<string name="create_key_final_text">You entered the following credentials:</string>
<string name="create_key_final_robot_text">Creating a key may take a while, have a cup of coffee in the meantime…\n(3 subkeys, RSA, 4096 bit)</string>
<!-- View key --> <!-- View key -->
<string name="view_key_revoked">This key has been revoked!</string> <string name="view_key_revoked">This key has been revoked!</string>