Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
5198894 Remove saveInstanceState
Browse files Browse the repository at this point in the history
ComposeMessageActivity has code in onSaveInstanceState to save
the working message, the recipients, and uri to the bundle.
In onCreate, this bundle was used to restore the conversation
and working message, regardless of the current intent. Since
the code is already saving and restoring the draft, let's
remove the saveInstanceState code. Bug 5198894

Change-Id: I038269020e4f02e1390b3a62a13278cfd72303ac
  • Loading branch information
Tom Taylor committed Aug 23, 2011
1 parent f5794fa commit 7d12894
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 76 deletions.
41 changes: 0 additions & 41 deletions src/com/android/mms/data/WorkingMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -831,47 +831,6 @@ public boolean isDiscarded() {
return mDiscarded;
}

/**
* To be called from our Activity's onSaveInstanceState() to give us a chance
* to stow our state away for later retrieval.
*
* @param bundle The Bundle passed in to onSaveInstanceState
*/
public void writeStateToBundle(Bundle bundle) {
if (hasSubject()) {
bundle.putString("subject", mSubject.toString());
}

if (mMessageUri != null) {
bundle.putParcelable("msg_uri", mMessageUri);
} else if (hasText()) {
bundle.putString("sms_body", mText.toString());
}
}

/**
* To be called from our Activity's onCreate() if the activity manager
* has given it a Bundle to reinflate
* @param bundle The Bundle passed in to onCreate
*/
public void readStateFromBundle(Bundle bundle) {
if (bundle == null) {
return;
}

String subject = bundle.getString("subject");
setSubject(subject, false);

Uri uri = (Uri)bundle.getParcelable("msg_uri");
if (uri != null) {
loadFromUri(uri);
return;
} else {
String body = bundle.getString("sms_body");
mText = body;
}
}

/**
* Update the temporary list of recipients, used when setting up a
* new conversation. Will be converted to a ContactList on any
Expand Down
39 changes: 7 additions & 32 deletions src/com/android/mms/ui/ComposeMessageActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1659,7 +1659,7 @@ protected void onCreate(Bundle savedInstanceState) {
mContentResolver = getContentResolver();
mBackgroundQueryHandler = new BackgroundQueryHandler(mContentResolver);

initialize(savedInstanceState, 0);
initialize(0);

if (TRACE) {
android.os.Debug.startMethodTracing("compose");
Expand Down Expand Up @@ -1698,24 +1698,24 @@ private void hideOrShowTopPanel() {
mTopPanel.setVisibility(anySubViewsVisible ? View.VISIBLE : View.GONE);
}

public void initialize(Bundle savedInstanceState, long originalThreadId) {
public void initialize(long originalThreadId) {
Intent intent = getIntent();

// Create a new empty working message.
mWorkingMessage = WorkingMessage.createEmpty(this);

// Read parameters or previously saved state of this activity. This will load a new
// mConversation
initActivityState(savedInstanceState, intent);
initActivityState(intent);

if (LogTag.SEVERE_WARNING && originalThreadId != 0 &&
originalThreadId == mConversation.getThreadId()) {
LogTag.warnPossibleRecipientMismatch("ComposeMessageActivity.initialize: " +
" threadId didn't change from: " + originalThreadId, this);
}

log("savedInstanceState = " + savedInstanceState +
" intent = " + intent +
log(" intent = " + intent +
"originalThreadId = " + originalThreadId +
" mConversation = " + mConversation);

if (cancelFailedToDeliverNotification(getIntent(), this)) {
Expand Down Expand Up @@ -1846,7 +1846,7 @@ protected void onNewIntent(Intent intent) {
}
saveDraft(); // if we've got a draft, save it first

initialize(null, originalThreadId);
initialize(originalThreadId);
loadMessageContent();
}

Expand Down Expand Up @@ -1942,19 +1942,6 @@ public void run() {
}, "updateSendFailedNotification").start();
}

@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);

outState.putString("recipients", getRecipients().serialize());

mWorkingMessage.writeStateToBundle(outState);

if (mExitOnSent) {
outState.putBoolean("exit_on_sent", mExitOnSent);
}
}

@Override
protected void onResume() {
super.onResume();
Expand Down Expand Up @@ -3341,19 +3328,7 @@ private long getMessageDate(Uri uri) {
return NO_DATE_FOR_DIALOG;
}

private void initActivityState(Bundle bundle, Intent intent) {
if (bundle != null) {
String recipients = bundle.getString("recipients");
if (LogTag.VERBOSE) log("get mConversation by recipients " + recipients);
mConversation = Conversation.get(this,
ContactList.getByNumbers(recipients,
false /* don't block */, true /* replace number */), false);
addRecipientsListeners();
mExitOnSent = bundle.getBoolean("exit_on_sent", false);
mWorkingMessage.readStateFromBundle(bundle);
return;
}

private void initActivityState(Intent intent) {
// If we have been passed a thread_id, use that to find our conversation.
long threadId = intent.getLongExtra("thread_id", 0);
if (threadId > 0) {
Expand Down
4 changes: 2 additions & 2 deletions tests/src/com/android/mms/ui/LongThreadTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public MenuItem setVisible(boolean visible) {

public void setShowAsAction(int actionEnum) {
// TODO Auto-generated method stub

}

@Override
Expand Down Expand Up @@ -402,7 +402,7 @@ public void testSendManyMessages() throws Throwable {
for (String recipient : mRecipients) {
a.runOnUiThread(new Runnable() {
public void run() {
a.initialize(null, 0);
a.initialize(0);
a.loadMessageContent();
}
});
Expand Down
2 changes: 1 addition & 1 deletion tests/src/com/android/mms/ui/MultiPartSmsTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void testLongSmsMessage() throws Throwable {
final ComposeMessageActivity a = getActivity();
a.runOnUiThread(new Runnable() {
public void run() {
a.initialize(null, 0);
a.initialize(0);
a.loadMessageContent();
}
});
Expand Down

0 comments on commit 7d12894

Please sign in to comment.