diff --git a/android/clientbeta/AndroidManifest.xml b/android/clientbeta/AndroidManifest.xml index 2918dce1..8df79438 100644 --- a/android/clientbeta/AndroidManifest.xml +++ b/android/clientbeta/AndroidManifest.xml @@ -2,7 +2,7 @@ + android:versionName="1.2.1_b7"> diff --git a/android/libraries/SocialNetLib/src/org/tweetalib/android/TwitterFetchUsers.java b/android/libraries/SocialNetLib/src/org/tweetalib/android/TwitterFetchUsers.java index 3debdbdb..7370da29 100644 --- a/android/libraries/SocialNetLib/src/org/tweetalib/android/TwitterFetchUsers.java +++ b/android/libraries/SocialNetLib/src/org/tweetalib/android/TwitterFetchUsers.java @@ -49,7 +49,7 @@ public void clearCallbacks() { } /* - * + * */ public interface FetchUsersWorkerCallbacks { @@ -734,12 +734,13 @@ protected FetchUsersTaskOutput doInBackground( while (check) { //Establish ids for this batch for (int i = start; i < finish; i++) { - fetchIds.add(ids[i]); if (ids.length - 1 == i) { check = false; break; } + + fetchIds.add(ids[i]); } //Mark where to start and end next time round diff --git a/android/libraries/SocialNetLib/src/org/tweetalib/android/model/TwitterStatus.java b/android/libraries/SocialNetLib/src/org/tweetalib/android/model/TwitterStatus.java index 7c5c5bf7..0a129406 100644 --- a/android/libraries/SocialNetLib/src/org/tweetalib/android/model/TwitterStatus.java +++ b/android/libraries/SocialNetLib/src/org/tweetalib/android/model/TwitterStatus.java @@ -175,9 +175,12 @@ public TwitterStatus(AdnPost post) { mInReplyToStatusId = post.mInReplyTo; mSource = post.mSource; - mUserId = post.mUser.mId; - mUserName = post.mUser.mName; - mUserScreenName = post.mUser.mUserName; + if(post.mUser != null) + { + mUserId = post.mUser.mId; + mUserName = post.mUser.mName; + mUserScreenName = post.mUser.mUserName; + } mIsFavorited = post.mIsFavorited; mIsRetweetedByMe = post.mIsRetweetedByMe; diff --git a/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/BaseLaneActivity.java b/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/BaseLaneActivity.java index a25bb26a..13c89db2 100644 --- a/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/BaseLaneActivity.java +++ b/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/BaseLaneActivity.java @@ -1239,14 +1239,29 @@ void configureActionBarSearchView(Menu menu) { public void onFocusChange(View v, boolean hasFocus) { mCurrentComposeFragment.setIgnoreFocusChange(true); + if (mComposeTweetView != null) { - mComposeTweetView.setVisibility(hasFocus ? View.GONE - : View.VISIBLE); + mComposeTweetView.setVisibility(View.GONE); } if (mComposeDirectMessageView != null) { - mComposeDirectMessageView - .setVisibility(hasFocus ? View.GONE : View.VISIBLE); + mComposeDirectMessageView.setVisibility(View.GONE); } + + if(!hasFocus) + { + if (mCurrentComposeFragment == mComposeDirectMessageFragment) { + if (mComposeDirectMessageView != null) { + mComposeDirectMessageView.setVisibility(View.VISIBLE); + } + } + else + { + if (mComposeTweetView != null) { + mComposeTweetView.setVisibility(View.VISIBLE); + } + } + } + mCurrentComposeFragment.setIgnoreFocusChange(false); } diff --git a/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/HomeActivity.java b/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/HomeActivity.java index 9353beb3..6f7c29b0 100644 --- a/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/HomeActivity.java +++ b/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/HomeActivity.java @@ -553,7 +553,10 @@ private void showAccount(AccountDescriptor selectedAccount, Constant.LaneType la clearFragmentsCache(); app.setCurrentAccount(selectedAccount.getId()); - mHomeLaneAdapter.notifyDataSetChanged(); + if(mHomeLaneAdapter != null) + { + mHomeLaneAdapter.notifyDataSetChanged(); + } // From http://stackoverflow.com/a/3419987/328679 Intent intent = getIntent(); diff --git a/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/InflatedLayoutFragment.java b/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/InflatedLayoutFragment.java index 84458363..7fc17558 100644 --- a/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/InflatedLayoutFragment.java +++ b/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/InflatedLayoutFragment.java @@ -88,7 +88,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); - if (outState != null) { + if (outState != null && mLayoutResourceId != null) { outState.putInt(KEY_RESOURCE_ID, mLayoutResourceId); } } diff --git a/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/TweetFeedFragment.java b/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/TweetFeedFragment.java index d3699df0..7502c670 100644 --- a/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/TweetFeedFragment.java +++ b/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/TweetFeedFragment.java @@ -17,6 +17,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ActivityInfo; +import android.content.res.Configuration; import android.os.Bundle; import android.os.Handler; import android.support.v4.content.LocalBroadcastManager; @@ -243,6 +244,25 @@ public void fetchNewestTweets() { } } + private void lockScreenRotation() { + if (getActivity() != null) { + switch (getActivity().getResources().getConfiguration().orientation) { + case Configuration.ORIENTATION_PORTRAIT: + getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + break; + case Configuration.ORIENTATION_LANDSCAPE: + getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); + break; + } + } + } + + private void resetScreenRotation() { + if (getActivity() != null) { + getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); + } + } + /* * */ @@ -253,9 +273,7 @@ void fetchNewestTweets(final long sinceStatusId, Long maxStatusId) { if (mTweetDataRefreshCallback == null) { if (maxStatusId == null) { - if (getActivity() != null) { - getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); - } + lockScreenRotation(); mTimesFetchCalled = 0; TwitterStatus visibleStatus = getVisibleStatus(); if (visibleStatus != null && mLastTwitterStatusIdSeen < visibleStatus.mId) { @@ -492,7 +510,7 @@ boolean configureCachedStatuses() { setStatusFeed(_mCachedStatusFeed, false); if (getStatusFeed() != null && mLastTwitterStatusIdSeen != null) { Integer index = getStatusFeed().getStatusIndex(mLastTwitterStatusIdSeen); - if(index != null){ + if (index != null) { updateListHeading(index); } } @@ -783,7 +801,7 @@ public void onClick(View v) { }; /* - * + * */ void setListHeadingVisiblilty(int value) { mListHeadingTextView.setVisibility(value); @@ -928,24 +946,33 @@ private void onRefreshFinished(TwitterStatuses feed) { } if (statusIndex != null) { - mTweetFeedListView.getRefreshableView() - .setSelectionFromTop(statusIndex.intValue() + 1, mScrollTracker.getFirstVisibleYOffset()); + int newIndex = statusIndex.intValue() + 1; + + if (mNewStatuses == 1 && getStatusFeed() != null) { + TwitterStatus firstStatus = getStatusFeed().getStatus(0); + if (firstStatus != null && firstStatus.getAuthorScreenName().equals(getApp().getCurrentAccount().getScreenName())) { + newIndex = statusIndex.intValue(); + } + } + + mTweetFeedListView.getRefreshableView().setSelectionFromTop(newIndex, mScrollTracker.getFirstVisibleYOffset()); if (visibleStatus != null && mLastTwitterStatusIdSeen < visibleStatus.mId) { mLastTwitterStatusIdSeen = visibleStatus.mId; } if (!mDetached) { - updateListHeading(statusIndex.intValue() + 1); + updateListHeading(newIndex); } } else { showToast(getString(R.string.lost_position)); } - mTweetDataRefreshCallback = null; - if (getActivity() != null) { - getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); + if (mNewStatuses == 0) { + mTweetFeedListView.getRefreshableView().setSelectionFromTop(0, mScrollTracker.getFirstVisibleYOffset()); } + mTweetDataRefreshCallback = null; + resetScreenRotation(); } /* @@ -1335,10 +1362,14 @@ public void finished(TwitterFetchResult result, TwitterStatus status) { TwitterStatus cachedStatus = cachedStatuses.findByStatusId(status.mOriginalRetweetId); if (cachedStatus != null) { cachedStatus.setRetweet(true); - showToast(getString(R.string.retweeted_successfully)); + if (!mDetached) { + showToast(getString(R.string.retweeted_successfully)); + } setIsRetweet(true); } else { - showToast(getString(R.string.retweeted_marking_un_successful)); + if (!mDetached) { + showToast(getString(R.string.retweeted_marking_un_successful)); + } } } else { if (result.getErrorMessage() == null) { @@ -1351,7 +1382,7 @@ public void finished(TwitterFetchResult result, TwitterStatus status) { showUnsuccessful = true; } - if (showUnsuccessful) { + if (showUnsuccessful && !mDetached) { showToast(getString(R.string.retweeted_un_successful)); } } @@ -1390,14 +1421,18 @@ public void finished(boolean successful, TwitterStatuses statuses, Integer value } } - showToast(getString(settingFavorited ? R.string.favorited_successfully : R.string - .unfavorited_successfully)); + if (!mDetached) { + showToast(getString(settingFavorited ? R.string.favorited_successfully : R.string + .unfavorited_successfully)); + } setIsFavorited(settingFavorited); } else { boolean newState = getSelectedFavoriteState() != ItemSelectedState.ALL; - showToast(getString(newState ? R.string.favorited_un_successfully : R.string - .unfavorited_un_successfully)); + if (!mDetached) { + showToast(getString(newState ? R.string.favorited_un_successfully : R.string + .unfavorited_un_successfully)); + } } } @@ -1429,7 +1464,9 @@ public void finished(boolean successful, TwitterStatuses statuses, Integer value _mCachedStatusFeed.remove(selectedStatuses); } } else { - showToast(getString(R.string.deleted_un_successfully)); + if (!mDetached) { + showToast(getString(R.string.deleted_un_successfully)); + } } } }; @@ -1470,23 +1507,25 @@ public void finished(TwitterFetchResult result, TwitterUsers users) { if (result.isSuccessful() && users != null && users.getUserCount() > 0) { int userCount = users.getUserCount(); String notice; - if (itemId == R.id.action_report_for_spam) { - if (userCount == 1) { - notice = "Reported @" + users.getUser(0).getScreenName() + - " for Spam."; + if (!mDetached) { + if (itemId == R.id.action_report_for_spam) { + if (userCount == 1) { + notice = "Reported @" + users.getUser(0).getScreenName() + + " for Spam."; + } else { + notice = "Reported " + userCount + " users for Spam."; + } } else { - notice = "Reported " + userCount + " users for Spam."; + if (userCount == 1) { + notice = "Blocked @" + users.getUser(0).getScreenName() + "."; + } else { + notice = "Blocked " + userCount + " users."; + } } - } else { - if (userCount == 1) { - notice = "Blocked @" + users.getUser(0).getScreenName() + "."; - } else { - notice = "Blocked " + userCount + " users."; + if (notice != null) { + showToast(notice); } } - if (notice != null) { - showToast(notice); - } } } }; diff --git a/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/TweetSpotlightFragment.java b/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/TweetSpotlightFragment.java index 4beaae66..f9be052c 100644 --- a/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/TweetSpotlightFragment.java +++ b/android/libraries/TweetLanesCore/src/com/tweetlanes/android/core/view/TweetSpotlightFragment.java @@ -153,7 +153,10 @@ public void finished(TwitterFetchResult result, }; mStatus = status; - TwitterManager.get().getStatus(mStatus.mOriginalRetweetId, mGetStatusCallback); + if(mStatus != null) + { + TwitterManager.get().getStatus(mStatus.mOriginalRetweetId, mGetStatusCallback); + } } else { onStatusRefresh(status); }