Skip to content

Commit

Permalink
Merge pull request #192 from BlythMeister/ReplyLost
Browse files Browse the repository at this point in the history
Fixes for #96
  • Loading branch information
Fammy committed Jul 15, 2013
2 parents 1014118 + 7955f9f commit 98dc987
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 40 deletions.
1 change: 1 addition & 0 deletions android/libraries/TweetLanesCore/res/xml/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<change>Fix - DM notifications load into DM lane</change>
<change>Fix - Retweets of Retweets now correctly stay marked as such</change>
<change>Fix - Correct handling of media URLs if the domain contains upper case characters</change>
<change>Fix - Replys, Attached images &amp; new tweet bar remain during orientation change</change>
<change>Other - Crittercism upgrade (making it easier for us to see when you have problems)</change>
</release>
<release version="1.1.4" versioncode="48">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@ public void saveTweetDraft(String draftAsJsonString) {
edit.commit();
}

/*
*
*/
public void clearTweetDraft() {
final Editor edit = mPreferences.edit();
edit.remove(getTweetDraftKey());
edit.remove(getTweetDraftTimeKey());
edit.commit();
}

/*
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@ void setCurrentComposeFragment(int type) {
}
}

void clearCompose()
{
mCurrentComposeFragment.clearCompose(false);
}

/*
*
*/
Expand Down Expand Up @@ -1131,6 +1136,8 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (fragment != null) {
fragment.UpdateTweetCache(status, deleteStatus);
}

clearCompose();
}
}

Expand Down Expand Up @@ -1376,8 +1383,21 @@ protected void setComposeTweetDefault() {
*
*/
protected void setComposeDefault() {
if (this.mCurrentComposeFragment == mComposeTweetFragment) {
setComposeTweetDefault();
if (this.mCurrentComposeFragment == mComposeTweetFragment)
{
String draft = mComposeTweetFragment.getTweetDefaultDraft();
if(draft == null || draft=="")
{
setComposeTweetDefault();
}
else
{
mComposeTweetFragment.updateStatusHint();
}
}
else
{
mComposeTweetFragment.clearCompose(false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ String getFormattedStatus(String status) {
public boolean releaseFocus(boolean saveCurrentTweet) {

clearCompose(saveCurrentTweet);
setMediaPreviewVisibility();
return hideCompose();
}

Expand Down Expand Up @@ -297,6 +298,7 @@ void hideKeyboard() {
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus == true && mIgnoreFocusChange == false) {
showCompose();
setMediaPreviewVisibility();
}
}
};
Expand All @@ -317,9 +319,13 @@ void setIgnoreFocusChange(boolean ignoreFocusChange) {
public void afterTextChanged(Editable s) {
String asString = s.toString();
configureCharacterCountForString(asString);
if (asString == null || asString.equals("") == true) {
setComposeTweetDefault(null);
updateStatusHint();
if (asString == null || asString.equals("") == true)
{
if (mListener.getDraft() == null)
{
setComposeTweetDefault(null);
updateStatusHint();
}
}

autoComplete(asString, mEditText);
Expand Down Expand Up @@ -619,6 +625,8 @@ public void onClick(View v) {

protected abstract void onSendClick(String status);

public abstract void setMediaPreviewVisibility();

/*
*/
EditClearTextListener mEditClearTextListener = new EditClearTextListener() {
Expand All @@ -640,18 +648,15 @@ public boolean onBackButtonPressed() {
mListener.onBackButtonPressed();
}
hideCompose();
setMediaPreviewVisibility();
return true;
}

@Override
public void onClearPressed() {
clearCompose(false);
}

@Override
public void onTouch(View v, MotionEvent event) {
if (mHasFocus == false) {
showCompose();
setMediaPreviewVisibility();
}
}
};
Expand All @@ -661,13 +666,20 @@ public void onTouch(View v, MotionEvent event) {
*/
void clearCompose(boolean saveCurrentTweet) {

if (saveCurrentTweet) {
if (saveCurrentTweet)
{
saveCurrentAsDraft();
updateComposeTweetDefault();
}
else
{
setComposeTweetDefault(null);

if (mListener != null) {
mListener.onMediaDetach();
}

setComposeTweetDefault(null);
if (mListener != null) {
mListener.onMediaDetach();
getApp().clearTweetDraft();
}

// NOTE: Changing these text values causes a crash during the copy/paste
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,22 @@ private String getOtherUserScreenName() {
return otherUserScreenName;
}

public void setMediaPreviewVisibility() {}

/*
*
*/
@Override
protected void updateComposeTweetDefault() {

ComposeTweetDefault composeTweetDefault = null;
protected void updateComposeTweetDefault()
{
String currentStatus = mEditText.getText().toString();

if (Util.isValidString(currentStatus)) {
composeTweetDefault = new ComposeTweetDefault(getApp()
ComposeTweetDefault composeTweetDefault = new ComposeTweetDefault(getApp()
.getCurrentAccountScreenName(), currentStatus, null, null);
}

setComposeTweetDefault(composeTweetDefault);
setComposeTweetDefault(composeTweetDefault);
}
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ protected void setComposeTweetDefault(
@Override
protected void updateComposeTweetDefault() {

ComposeTweetDefault composeTweetDefault = null;
String currentStatus = mEditText.getText().toString();

if (Util.isValidString(currentStatus)) {
composeTweetDefault = new ComposeTweetDefault(getApp()
if (Util.isValidString(currentStatus))
{
ComposeTweetDefault composeTweetDefault = new ComposeTweetDefault(getApp()
.getCurrentAccountScreenName(), currentStatus,
getInReplyToId(), getMediaFilePath());
}

setComposeTweetDefault(composeTweetDefault);
setComposeTweetDefault(composeTweetDefault);
}
}

/*
Expand All @@ -108,6 +108,19 @@ protected String getTweetDefaultDraft() {
return result;
}
}
else
{
if (mListener != null) {
String draftAsJsonString = mListener.getDraft();
if (draftAsJsonString != null && draftAsJsonString.equals("") == false)
{
return draftAsJsonString;
}
}
}



return null;
}

Expand Down Expand Up @@ -356,6 +369,7 @@ protected void updateStatusHint() {
ComposeTweetDefault draft = new ComposeTweetDefault(
draftAsJsonString);
hint = getStatusHint(draft);
setComposeTweetDefault(draft);
}
}

Expand Down Expand Up @@ -389,7 +403,7 @@ void setMediaFilePath(String filePath) {
/*
*
*/
private void setMediaPreviewVisibility() {
public void setMediaPreviewVisibility() {
mAttachImagePreview.setVisibility(View.GONE);

if (_mComposeDefault != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,26 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
LocalBroadcastManager.getInstance(getActivity())
.registerReceiver(mVolumeDownKeyDownReceiver, new IntentFilter("" + SystemEvent.VOLUME_DOWN_KEY_DOWN));


if(savedInstanceState != null)
{
mTwitterStatusIdWhenRefreshed = savedInstanceState.getLong("TwitterStatusIdWhenRefreshed");
mLastTwitterStatusIdSeen = savedInstanceState.getLong("LastTwitterStatusIdSeen");
mNewStatuses = savedInstanceState.getInt("NewStatuses",0);
}

return resultView;
}

@Override
public void onSaveInstanceState(Bundle state)
{
super.onSaveInstanceState(state);
if (mTwitterStatusIdWhenRefreshed != null) state.putLong("TwitterStatusIdWhenRefreshed", mTwitterStatusIdWhenRefreshed);
if (mLastTwitterStatusIdSeen != null) state.putLong("LastTwitterStatusIdSeen", mLastTwitterStatusIdSeen);
state.putInt("NewStatuses", mNewStatuses);
}

/*
*
*/
Expand Down Expand Up @@ -1024,11 +1041,13 @@ public void run() {
private boolean onTweetFeedItemSingleTap(View view, int position) {

if (mSelectedItems.size() == 0) {

TweetFeedItemView tweetFeedItemView = (TweetFeedItemView) (view);
TwitterStatus status = tweetFeedItemView.getTwitterStatus();
Intent tweetSpotlightIntent = new Intent(getActivity(), TweetSpotlightActivity.class);
tweetSpotlightIntent.putExtra("statusId", Long.toString(status.mId));
tweetSpotlightIntent.putExtra("status", status.toString());
tweetSpotlightIntent.putExtra("clearCompose", "true");
getActivity().startActivityForResult(tweetSpotlightIntent, Constant.REQUEST_CODE_SPOTLIGHT );
return true;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ protected void onCreate(Bundle savedInstanceState) {

String statusIdAsString = getIntent().getStringExtra(STATUS_ID_KEY);
String statusAsString = getIntent().getStringExtra(STATUS_KEY);
String clearCompose = getIntent().getStringExtra("clearCompose");

long statusId = 0;
if (statusIdAsString != null) {
statusId = Long.parseLong(statusIdAsString);
Expand All @@ -74,6 +76,13 @@ protected void onCreate(Bundle savedInstanceState) {
super.setCurrentComposeFragment((fragment instanceof DirectMessageFeedFragment) ? super.COMPOSE_DIRECT_MESSAGE
: super.COMPOSE_TWEET);


if(clearCompose != null && clearCompose.equals("true"))
{
clearCompose();
getIntent().removeExtra("clearCompose");
}

mViewSwitcher = (ViewSwitcher) findViewById(R.id.rootViewSwitcher);
updateViewVisibility();

Expand Down Expand Up @@ -342,15 +351,6 @@ public boolean configureOptionsMenu(Menu menu) {
return false;
}

@Override
public boolean composeReleaseFocus(boolean forceCleanup) {
boolean result = super.composeReleaseFocus(forceCleanup);

super.setComposeTweetDefault(getComposeTweetDefault());

return result;
}

void setIsFavorited()
{
if(mFavoriteMenuItem != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ public interface EditClearTextListener {
*/
public boolean onBackButtonPressed();

/*
* Triggered when the clear button is pressed
*/
public void onClearPressed();

/*
* Triggered when the view is touched. Use as a replacement for
* setOnTouchListener(), which EditClearText overrides
Expand Down

0 comments on commit 98dc987

Please sign in to comment.