mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-25 15:11:52 -05:00
Save and restore the cursor position when saving or loading a draft. This is the first step in making "resume composition on context switch" a reality.
This commit is contained in:
parent
3255b403fc
commit
e5d952bff4
@ -1139,7 +1139,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||||||
NAME("n"),
|
NAME("n"),
|
||||||
EMAIL("e"),
|
EMAIL("e"),
|
||||||
// TODO - store a reference to the message being replied so we can mark it at the time of send.
|
// TODO - store a reference to the message being replied so we can mark it at the time of send.
|
||||||
ORIGINAL_MESSAGE("m");
|
ORIGINAL_MESSAGE("m"),
|
||||||
|
CURSOR_POSITION("p"); // Where in the message your cursor was when you saved.
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|
||||||
@ -1202,6 +1203,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||||||
uri.appendQueryParameter(IdentityField.ORIGINAL_MESSAGE.value(), mMessageReference.toIdentityString());
|
uri.appendQueryParameter(IdentityField.ORIGINAL_MESSAGE.value(), mMessageReference.toIdentityString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uri.appendQueryParameter(IdentityField.CURSOR_POSITION.value(), Integer.toString(mMessageContentView.getSelectionStart()));
|
||||||
|
|
||||||
String k9identity = IDENTITY_VERSION_1 + uri.build().getEncodedQuery();
|
String k9identity = IDENTITY_VERSION_1 + uri.build().getEncodedQuery();
|
||||||
|
|
||||||
if (K9.DEBUG) {
|
if (K9.DEBUG) {
|
||||||
@ -2047,6 +2050,15 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cursorPosition = 0;
|
||||||
|
if(k9identity.containsKey(IdentityField.CURSOR_POSITION)) {
|
||||||
|
try {
|
||||||
|
cursorPosition = Integer.valueOf(k9identity.get(IdentityField.CURSOR_POSITION)).intValue();
|
||||||
|
} catch(Exception e) {
|
||||||
|
Log.e(K9.LOG_TAG, "Could not parse cursor position for MessageCompose; continuing.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mIdentity = newIdentity;
|
mIdentity = newIdentity;
|
||||||
|
|
||||||
updateSignature();
|
updateSignature();
|
||||||
@ -2151,6 +2163,13 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
|
|||||||
Log.e(K9.LOG_TAG, "Unhandled message format.");
|
Log.e(K9.LOG_TAG, "Unhandled message format.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the cursor position if we have it.
|
||||||
|
try {
|
||||||
|
mMessageContentView.setSelection(cursorPosition);
|
||||||
|
} catch(Exception e) {
|
||||||
|
Log.e(K9.LOG_TAG, "Could not set cursor position in MessageCompose; ignoring.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (MessagingException me) {
|
} catch (MessagingException me) {
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user