Skip to content

Commit

Permalink
some improvements and bug fixes. no feature addition
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Sep 28, 2012
1 parent fbb6c3d commit d195b2e
Show file tree
Hide file tree
Showing 15 changed files with 110 additions and 47 deletions.
5 changes: 2 additions & 3 deletions res/layout-ar/user_profile_header.xml
Expand Up @@ -192,8 +192,7 @@
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_weight="0"
android:minWidth="72dp"
android:visibility="gone">
android:minWidth="72dp">

<Button
android:id="@+id/more_options"
Expand Down Expand Up @@ -353,4 +352,4 @@
android:layout_height="0.2dp"
android:background="#40808080"/>

</LinearLayout>
</LinearLayout>
5 changes: 2 additions & 3 deletions res/layout/user_profile_header.xml
Expand Up @@ -213,8 +213,7 @@
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_weight="0"
android:minWidth="72dp"
android:visibility="gone">
android:minWidth="72dp">

<Button
android:id="@+id/more_options"
Expand Down Expand Up @@ -344,4 +343,4 @@
android:layout_height="0.2dp"
android:background="#40808080"/>

</LinearLayout>
</LinearLayout>
21 changes: 18 additions & 3 deletions res/menu/action_status.xml
Expand Up @@ -10,15 +10,30 @@
android:icon="@drawable/ic_menu_reply"
android:title="@string/reply"/>
<item
android:id="@id/retweet"
android:id="@+id/retweet_submenu"
android:icon="@drawable/ic_menu_retweet"
android:title="@string/retweet">
<menu>
<item
android:id="@id/retweet"
android:icon="@drawable/ic_menu_retweet"
android:title="@string/retweet"/>
<item
android:id="@id/quote"
android:icon="@drawable/ic_menu_quote"
android:title="@string/quote"/>
</menu>
</item>
<item
android:id="@+id/direct_retweet"
android:icon="@drawable/ic_menu_retweet"
android:title="@string/retweet"/>
<item
android:id="@id/quote"
android:id="@+id/direct_quote"
android:icon="@drawable/ic_menu_quote"
android:title="@string/quote"/>
<item
android:id="@id/fav"
android:id="@id/favorite"
android:icon="@drawable/ic_menu_star"
android:title="@string/fav"/>
<item
Expand Down
4 changes: 2 additions & 2 deletions res/menu/menu_status.xml
Expand Up @@ -21,7 +21,7 @@
</menu>
</item>
<item
android:id="@id/fav"
android:id="@id/favorite"
android:icon="@drawable/ic_menu_star"
android:title="@string/fav"/>
<item
Expand Down Expand Up @@ -74,4 +74,4 @@
</menu>
</item>

</menu>
</menu>
4 changes: 2 additions & 2 deletions res/values/ids.xml
Expand Up @@ -19,7 +19,7 @@
<item name="pick_from_map" type="id"/>
<item name="reply" type="id"/>
<item name="retweet" type="id"/>
<item name="fav" type="id"/>
<item name="favorite" type="id"/>
<item name="share" type="id"/>
<item name="edit_api" type="id"/>
<item name="set_color" type="id"/>
Expand Down Expand Up @@ -51,4 +51,4 @@
<item name="multi_select" type="id"/>
<item name="clear_color" type="id"/>

</resources>
</resources>
4 changes: 4 additions & 0 deletions res/values/strings.xml
Expand Up @@ -341,5 +341,9 @@
<string name="click_to_open_menu_summary">Click to open item menu, long-click to multi select.</string>
<string name="send_follow_request">Send follow request</string>
<string name="follow_request_sent">Follow request sent</string>
<string name="keep_in_background">Keep home activity in background</string>
<string name="keep_in_background_summary">Consumes more memory, but may faster to launch.</string>
<string name="seprate_retweet_action">Seprate retweet action</string>
<string name="seprate_retweet_action_summary">Show both retweet and quote action in tweet menu</string>

</resources>
5 changes: 5 additions & 0 deletions res/xml/settings_appearance.xml
Expand Up @@ -16,6 +16,11 @@
android:key="click_to_open_menu"
android:summary="@string/click_to_open_menu_summary"
android:title="@string/click_to_open_menu"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="seprate_retweet_action"
android:summary="@string/seprate_retweet_action_summary"
android:title="@string/seprate_retweet_action"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="bottom_compose_button"
Expand Down
10 changes: 8 additions & 2 deletions res/xml/settings_other.xml
Expand Up @@ -13,12 +13,18 @@
android:defaultValue="false"
android:key="quick_send"
android:summary="@string/quick_send_summary"
android:title="@string/quick_send"/>
android:title="@string/quick_send"/>
<CheckBoxPreference
android:defaultValue="false"
android:dependency="stop_service_after_closed"
android:key="keep_in_background"
android:summary="@string/keep_in_background_summary"
android:title="@string/keep_in_background"/>
<CheckBoxPreference
android:defaultValue="false"
android:disableDependentsState="true"
android:key="stop_service_after_closed"
android:summary="@string/stop_service_after_closed_summary"
android:title="@string/stop_service_after_closed"/>

</PreferenceScreen>
</PreferenceScreen>
4 changes: 3 additions & 1 deletion src/org/mariotaku/twidere/Constants.java
Expand Up @@ -185,6 +185,8 @@ public interface Constants extends TwitterConstants {
public static final String PREFERENCE_KEY_TCP_DNS_QUERY = "tcp_dns_query";
public static final String PREFERENCE_KEY_DNS_SERVER = "dns_server";
public static final String PREFERENCE_KEY_CLICK_TO_OPEN_MENU = "click_to_open_menu";
public static final String PREFERENCE_KEY_KEEP_IN_BACKGROUND = "keep_in_background";
public static final String PREFERENCE_KEY_SEPRATE_RETWEET_ACTION = "seprate_retweet_action";

public static final String PREFERENCE_DEFAULT_QUOTE_FORMAT = "RT @" + FORMAT_PATTERN_NAME + ": "
+ FORMAT_PATTERN_TEXT;
Expand Down Expand Up @@ -355,7 +357,7 @@ public interface Constants extends TwitterConstants {
public static final int MENU_SET_COLOR = R.id.set_color;
public static final int MENU_ADD_ACCOUNT = R.id.add_account;
public static final int MENU_REPLY = R.id.reply;
public static final int MENU_FAV = R.id.fav;
public static final int MENU_FAVORITE = R.id.favorite;
public static final int MENU_RETWEET = R.id.retweet;
public static final int MENU_QUOTE = R.id.quote;
public static final int MENU_SHARE = R.id.share;
Expand Down
Expand Up @@ -251,7 +251,7 @@ class AccountPreference extends Preference implements Constants, OnPreferenceCli

public AccountPreference(final Context context) {
super(context);
final List<Account> accounts = Account.getAccounts(getContext(), true);
final List<Account> accounts = Account.getAccounts(getContext(), false);
mAccounts = accounts.toArray(new Account[accounts.size()]);
setTitle(R.string.account);
if (mAccountId > 0) {
Expand Down
12 changes: 12 additions & 0 deletions src/org/mariotaku/twidere/activity/HomeActivity.java
Expand Up @@ -132,6 +132,18 @@ public boolean checkDefaultAccountSet() {
}
return result;
}

@Override
public void onBackPressed() {
final FragmentManager fm = getSupportFragmentManager();
if (fm.getBackStackEntryCount() == 0 &&
!mPreferences.getBoolean(PREFERENCE_KEY_STOP_SERVICE_AFTER_CLOSED, false) &&
mPreferences.getBoolean(PREFERENCE_KEY_KEEP_IN_BACKGROUND, false)) {
moveTaskToBack(true);
return;
}
super.onBackPressed();
}

@Override
public void onBackStackChanged() {
Expand Down
20 changes: 18 additions & 2 deletions src/org/mariotaku/twidere/fragment/BaseStatusesListFragment.java
Expand Up @@ -258,6 +258,7 @@ public boolean onMenuItemClick(final MenuItem item) {
startActivity(Intent.createChooser(intent, getString(R.string.share)));
break;
}
case R.id.direct_retweet:
case MENU_RETWEET: {
if (isMyRetweet(status)) {
mService.cancelRetweet(status.account_id, status.status_id);
Expand All @@ -268,6 +269,7 @@ public boolean onMenuItemClick(final MenuItem item) {
}
break;
}
case R.id.direct_quote:
case MENU_QUOTE: {
final Intent intent = new Intent(INTENT_ACTION_COMPOSE);
final Bundle bundle = new Bundle();
Expand Down Expand Up @@ -296,7 +298,7 @@ public boolean onMenuItemClick(final MenuItem item) {
startActivity(intent);
break;
}
case MENU_FAV: {
case MENU_FAVORITE: {
if (mSelectedStatus.is_favorite) {
mService.destroyFavorite(status.account_id, status.status_id);
} else {
Expand Down Expand Up @@ -430,15 +432,29 @@ public void onStop() {
}

private void openMenu(final View view, final ParcelableStatus status) {
if (view == null || status == null) return;
mPopupMenu = PopupMenu.getInstance(getActivity(), view);
mPopupMenu.inflate(R.menu.action_status);
final boolean click_to_open_menu = mPreferences.getBoolean(PREFERENCE_KEY_CLICK_TO_OPEN_MENU, false);
final boolean seprate_retweet_action = mPreferences.getBoolean(PREFERENCE_KEY_SEPRATE_RETWEET_ACTION, false);
final Menu menu = mPopupMenu.getMenu();
setMenuForStatus(getActivity(), menu, status);
final MenuItem itemView = menu.findItem(MENU_VIEW);
if (itemView != null) {
itemView.setVisible(click_to_open_menu);
}
setMenuForStatus(getActivity(), menu, status);
final MenuItem itemRetweetSubMenu = menu.findItem(R.id.retweet_submenu);
if (itemRetweetSubMenu != null) {
itemRetweetSubMenu.setVisible(!seprate_retweet_action);
}
final MenuItem itemDirectQuote = menu.findItem(R.id.direct_quote);
if (itemDirectQuote != null) {
itemDirectQuote.setVisible(seprate_retweet_action);
}
final MenuItem itemDirectRetweet = menu.findItem(R.id.direct_retweet);
if (itemDirectRetweet != null) {
itemDirectRetweet.setVisible(seprate_retweet_action && !status.is_protected);
}
mPopupMenu.setOnMenuItemClickListener(this);
mPopupMenu.show();
}
Expand Down
2 changes: 1 addition & 1 deletion src/org/mariotaku/twidere/fragment/StatusFragment.java
Expand Up @@ -499,7 +499,7 @@ public boolean onMenuItemClick(final MenuItem item) {
startActivity(intent);
break;
}
case MENU_FAV: {
case MENU_FAVORITE: {
if (mStatus.is_favorite) {
mService.destroyFavorite(mAccountId, mStatusId);
} else {
Expand Down
51 changes: 28 additions & 23 deletions src/org/mariotaku/twidere/fragment/UserProfileFragment.java
Expand Up @@ -125,7 +125,7 @@ public class UserProfileFragment extends BaseListFragment implements OnClickList
private LazyImageLoader mProfileImageLoader;

private ImageView mProfileImageView;
private View mFollowContainer, mMoreOptionsContainer;
private View mFollowContainer;
private TextView mNameView, mScreenNameView, mDescriptionView, mLocationView, mURLView, mCreatedAtView,
mTweetCount, mFollowersCount, mFriendsCount, mFollowedYouIndicator, mErrorMessageView;
private View mNameContainer, mProfileImageContainer, mDescriptionContainer, mLocationContainer, mURLContainer,
Expand Down Expand Up @@ -237,7 +237,6 @@ public Loader<Response<Relationship>> onCreateLoader(final int id, final Bundle
mFollowContainer.setVisibility(user_is_me ? View.GONE : View.VISIBLE);
mFollowButton.setVisibility(View.GONE);
mFollowProgress.setVisibility(View.VISIBLE);
mMoreOptionsContainer.setVisibility(user_is_me ? View.GONE : View.VISIBLE);
mMoreOptionsButton.setVisibility(View.GONE);
mMoreOptionsProgress.setVisibility(View.VISIBLE);
return new GetFriendshipLoader(getActivity(), mAccountId, mUserId);
Expand Down Expand Up @@ -280,11 +279,8 @@ public void onLoadFinished(final Loader<Response<Relationship>> loader, final Re
}
}
}
if (!user_is_me) {
mFollowContainer.setVisibility(data.value == null ? View.GONE : View.VISIBLE);
mMoreOptionsContainer.setVisibility(data.value == null ? View.GONE : View.VISIBLE);
mMoreOptionsButton.setVisibility(data.value == null ? View.GONE : View.VISIBLE);
}
mFollowContainer.setVisibility(data.value == null || user_is_me ? View.GONE : View.VISIBLE);
mMoreOptionsButton.setVisibility(data.value != null || user_is_me ? View.VISIBLE : View.GONE);
mFollowProgress.setVisibility(View.GONE);
mMoreOptionsProgress.setVisibility(View.GONE);
}
Expand Down Expand Up @@ -520,25 +516,35 @@ public void onClick(final View view) {
break;
}
case R.id.more_options: {
if (mUser == null || mFriendship == null || mAccountId == mUserId) return;
if (mUser == null) return;
mPopupMenu = PopupMenu.getInstance(getActivity(), view);
mPopupMenu.inflate(R.menu.action_user_profile);
final Menu menu = mPopupMenu.getMenu();
final MenuItem blockItem = menu.findItem(MENU_BLOCK);
if (blockItem != null) {
final Drawable blockIcon = blockItem.getIcon();
if (mFriendship.isSourceBlockingTarget()) {
blockItem.setTitle(R.string.unblock);
blockIcon.mutate().setColorFilter(getResources().getColor(R.color.holo_blue_bright),
PorterDuff.Mode.MULTIPLY);
} else {
blockItem.setTitle(R.string.block);
blockIcon.clearColorFilter();
if (mUser.getId() != mAccountId) {
if (mFriendship == null) return;
final MenuItem blockItem = menu.findItem(MENU_BLOCK);
if (blockItem != null) {
final Drawable blockIcon = blockItem.getIcon();
if (mFriendship.isSourceBlockingTarget()) {
blockItem.setTitle(R.string.unblock);
blockIcon.mutate().setColorFilter(getResources().getColor(R.color.holo_blue_bright),
PorterDuff.Mode.MULTIPLY);
} else {
blockItem.setTitle(R.string.block);
blockIcon.clearColorFilter();
}
}
final MenuItem sendDirectMessageItem = menu.findItem(MENU_SEND_DIRECT_MESSAGE);
if (sendDirectMessageItem != null) {
sendDirectMessageItem.setVisible(mFriendship.isTargetFollowingSource());
}
} else {
final int size = menu.size();
for (int i = 0; i < size; i++) {
final MenuItem item = menu.getItem(i);
final int id = item.getItemId();
item.setVisible(id == R.id.set_color_submenu || id == MENU_EXTENSIONS);
}
}
final MenuItem sendDirectMessageItem = menu.findItem(MENU_SEND_DIRECT_MESSAGE);
if (sendDirectMessageItem != null) {
sendDirectMessageItem.setVisible(mFriendship.isTargetFollowingSource());
}
mPopupMenu.setOnMenuItemClickListener(this);
mPopupMenu.show();
Expand Down Expand Up @@ -573,7 +579,6 @@ public View onCreateView(final LayoutInflater inflater, final ViewGroup containe
mFollowContainer = mHeaderView.findViewById(R.id.follow_container);
mFollowButton = (Button) mHeaderView.findViewById(R.id.follow);
mFollowProgress = (ProgressBar) mHeaderView.findViewById(R.id.follow_progress);
mMoreOptionsContainer = mHeaderView.findViewById(R.id.more_options_container);
mMoreOptionsButton = (Button) mHeaderView.findViewById(R.id.more_options);
mMoreOptionsProgress = (ProgressBar) mHeaderView.findViewById(R.id.more_options_progress);
mFollowedYouIndicator = (TextView) mHeaderView.findViewById(R.id.followed_you_indicator);
Expand Down
8 changes: 4 additions & 4 deletions src/org/mariotaku/twidere/util/Utils.java
Expand Up @@ -491,7 +491,7 @@ public static synchronized void cleanDatabasesByItemLimit(final Context context)
final StringBuilder where = new StringBuilder();
where.append(Statuses._ID + " NOT IN (");
where.append(" SELECT " + CachedUsers._ID + " FROM " + table);
where.append(" LIMIT " + (int) (Math.sqrt(item_limit) * 16) + ")");
where.append(" LIMIT " + (int) (Math.sqrt(item_limit) * 100) + ")");
resolver.delete(uri, where.toString(), null);
}
}
Expand Down Expand Up @@ -988,8 +988,8 @@ public static ImageSpec getImglyImage(final String id) {

public static ImageSpec getImgurImage(final String id) {
if (isNullOrEmpty(id)) return null;
final String thumbnail_size = "https://i.imgur.com/" + id + "s.jpg";
final String full_size = "https://i.imgur.com/" + id + ".jpg";
final String thumbnail_size = "http://i.imgur.com/" + id + "s.jpg";
final String full_size = "http://i.imgur.com/" + id + ".jpg";
return new ImageSpec(thumbnail_size, full_size);
}

Expand Down Expand Up @@ -2499,7 +2499,7 @@ public static void setMenuForStatus(final Context context, final Menu menu, fina
itemRetweet.setTitle(R.string.retweet);
}
}
final MenuItem itemFav = menu.findItem(MENU_FAV);
final MenuItem itemFav = menu.findItem(MENU_FAVORITE);
if (itemFav != null) {
final Drawable iconFav = itemFav.getIcon();
if (status.is_favorite) {
Expand Down

0 comments on commit d195b2e

Please sign in to comment.