fix transition animation

This commit is contained in:
Vincent Breitmoser
2015-03-09 16:56:10 +01:00
parent 08fd2a2de3
commit 138773798a
3 changed files with 41 additions and 9 deletions

View File

@@ -24,9 +24,8 @@ import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.os.Handler;
import android.support.v4.app.LoaderManager; import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader; import android.support.v4.content.Loader;
import android.support.v7.widget.CardView; import android.support.v7.widget.CardView;
import android.transition.Fade; import android.transition.Fade;
@@ -42,10 +41,11 @@ import android.widget.ListView;
import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.ui.adapter.LinkedIdsAdapter; import org.sufficientlysecure.keychain.ui.adapter.LinkedIdsAdapter;
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
import org.sufficientlysecure.keychain.ui.dialog.UserIdInfoDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.UserIdInfoDialogFragment;
import org.sufficientlysecure.keychain.ui.linked.LinkedIdViewFragment;
import org.sufficientlysecure.keychain.ui.linked.LinkedIdViewFragment.OnIdentityLoadedListener;
import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Log;
public class ViewKeyFragment extends LoaderFragment implements public class ViewKeyFragment extends LoaderFragment implements
@@ -129,7 +129,7 @@ public class ViewKeyFragment extends LoaderFragment implements
} }
private void showLinkedId(final int position) { private void showLinkedId(final int position) {
Fragment frag; final LinkedIdViewFragment frag;
try { try {
frag = mLinkedIdsAdapter.getLinkedIdFragment(mDataUri, position, mFingerprint); frag = mLinkedIdsAdapter.getLinkedIdFragment(mDataUri, position, mFingerprint);
} catch (IOException e) { } catch (IOException e) {
@@ -146,10 +146,27 @@ public class ViewKeyFragment extends LoaderFragment implements
} }
getFragmentManager().beginTransaction() getFragmentManager().beginTransaction()
.replace(R.id.view_key_fragment, frag) .add(R.id.view_key_fragment, frag)
.addSharedElement(mLinkedIdsCard, "card_linked_ids") .hide(frag)
.addToBackStack("linked_id")
.commit(); .commit();
frag.setOnIdentityLoadedListener(new OnIdentityLoadedListener() {
@Override
public void onIdentityLoaded() {
new Handler().post(new Runnable() {
@Override
public void run() {
getFragmentManager().beginTransaction()
.show(frag)
.addSharedElement(mLinkedIdsCard, "card_linked_ids")
.remove(ViewKeyFragment.this)
.addToBackStack("linked_id")
.commit();
}
});
}
});
} }
private void showUserIdInfo(final int position) { private void showUserIdInfo(final int position) {

View File

@@ -126,7 +126,7 @@ public class LinkedIdsAdapter extends UserAttributesAdapter {
UserIdsAdapter.USER_PACKETS_PROJECTION, LINKED_IDS_WHERE, null, null); UserIdsAdapter.USER_PACKETS_PROJECTION, LINKED_IDS_WHERE, null, null);
} }
public Fragment getLinkedIdFragment(Uri baseUri, public LinkedIdViewFragment getLinkedIdFragment(Uri baseUri,
int position, byte[] fingerprint) throws IOException { int position, byte[] fingerprint) throws IOException {
Cursor c = getCursor(); Cursor c = getCursor();

View File

@@ -79,8 +79,9 @@ public class LinkedIdViewFragment extends Fragment implements
private ViewHolder mViewHolder; private ViewHolder mViewHolder;
private View mCurrentCert; private View mCurrentCert;
private int mLidRank; private int mLidRank;
private OnIdentityLoadedListener mIdLoadedListener;
public static Fragment newInstance(Uri dataUri, int rank, public static LinkedIdViewFragment newInstance(Uri dataUri, int rank,
boolean showCertified, byte[] fingerprint) throws IOException { boolean showCertified, byte[] fingerprint) throws IOException {
LinkedIdViewFragment frag = new LinkedIdViewFragment(); LinkedIdViewFragment frag = new LinkedIdViewFragment();
@@ -149,6 +150,12 @@ public class LinkedIdViewFragment extends Fragment implements
RawLinkedIdentity linkedId = LinkedIdentity.fromAttributeData(data); RawLinkedIdentity linkedId = LinkedIdentity.fromAttributeData(data);
loadIdentity(linkedId, certStatus); loadIdentity(linkedId, certStatus);
if (mIdLoadedListener != null) {
mIdLoadedListener.onIdentityLoaded();
mIdLoadedListener = null;
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
throw new AssertionError("reconstruction of user attribute must succeed!"); throw new AssertionError("reconstruction of user attribute must succeed!");
@@ -162,6 +169,14 @@ public class LinkedIdViewFragment extends Fragment implements
} }
} }
public interface OnIdentityLoadedListener {
public void onIdentityLoaded();
}
public void setOnIdentityLoadedListener(OnIdentityLoadedListener listener) {
mIdLoadedListener = listener;
}
private void loadIdentity(RawLinkedIdentity linkedId, int certStatus) { private void loadIdentity(RawLinkedIdentity linkedId, int certStatus) {
mLinkedId = linkedId; mLinkedId = linkedId;