diff --git a/ring-android/app/src/main/java/cx/ring/client/AccountWizard.java b/ring-android/app/src/main/java/cx/ring/client/AccountWizard.java index 3cdbb69e9ff6f1b54063720036e81f28ddcc4eec..b6f38f2699e69185969dd504da0b7f16889bab78 100644 --- a/ring-android/app/src/main/java/cx/ring/client/AccountWizard.java +++ b/ring-android/app/src/main/java/cx/ring/client/AccountWizard.java @@ -32,6 +32,7 @@ import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.res.Configuration; import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; @@ -151,7 +152,10 @@ public class AccountWizard extends AppCompatActivity implements Observer<Service } else { mProfileFragment = (ProfileCreationFragment) getFragmentManager().getFragment(savedInstanceState, PROFILE_TAG); mFullname = savedInstanceState.getString("mFullname"); - mPhotoProfile = savedInstanceState.getParcelable("mPhotoProfile"); + byte[] bytes = savedInstanceState.getByteArray("mPhotoProfile"); + if (bytes != null && bytes.length > 0) { + mPhotoProfile = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); + } mLinkAccount = savedInstanceState.getBoolean("mLinkAccount"); } } @@ -163,7 +167,11 @@ public class AccountWizard extends AppCompatActivity implements Observer<Service getFragmentManager().putFragment(outState, PROFILE_TAG, mProfileFragment); } outState.putString("mFullname", mFullname); - outState.putParcelable("mPhotoProfile", mPhotoProfile); + if (mPhotoProfile != null) { + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + mPhotoProfile.compress(Bitmap.CompressFormat.PNG, 100, stream); + outState.putByteArray("mPhotoProfile", stream.toByteArray()); + } outState.putBoolean("mLinkAccount", mLinkAccount); } diff --git a/ring-android/app/src/main/java/cx/ring/fragments/ProfileCreationFragment.java b/ring-android/app/src/main/java/cx/ring/fragments/ProfileCreationFragment.java index 410ce205289bb5c9914a13c1e853bffd853f6089..a99d06b14fe538f8ac1e1c1b55c33c9cc14c4a87 100644 --- a/ring-android/app/src/main/java/cx/ring/fragments/ProfileCreationFragment.java +++ b/ring-android/app/src/main/java/cx/ring/fragments/ProfileCreationFragment.java @@ -31,7 +31,6 @@ import android.os.Bundle; import android.provider.ContactsContract; import android.provider.MediaStore; import android.support.v4.app.ActivityCompat; -import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -41,6 +40,8 @@ import android.widget.EditText; import android.widget.ImageButton; import android.widget.ImageView; +import java.io.ByteArrayOutputStream; + import javax.inject.Inject; import butterknife.BindView; @@ -90,7 +91,10 @@ public class ProfileCreationFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { if (savedInstanceState != null) { - mSourcePhoto = savedInstanceState.getParcelable(PHOTO_TAG); + byte[] bytes = savedInstanceState.getByteArray(PHOTO_TAG); + if (bytes != null && bytes.length > 0) { + mSourcePhoto = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); + } } final View view = inflater.inflate(R.layout.frag_acc_profile_create, parent, false); @@ -112,7 +116,11 @@ public class ProfileCreationFragment extends Fragment { @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - outState.putParcelable(PHOTO_TAG, mSourcePhoto); + if (mSourcePhoto != null) { + ByteArrayOutputStream stream = new ByteArrayOutputStream(); + mSourcePhoto.compress(Bitmap.CompressFormat.PNG, 100, stream); + outState.putByteArray(PHOTO_TAG, stream.toByteArray()); + } } private void initProfile() {