Skip to content

Commit

Permalink
added saved searches screen
Browse files Browse the repository at this point in the history
improved theme
added twitter card in search results
  • Loading branch information
mariotaku committed Apr 18, 2015
1 parent 9f75af1 commit d4a8bbb
Show file tree
Hide file tree
Showing 19 changed files with 175 additions and 178 deletions.
4 changes: 3 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ I started a crowdin project, so anyone can do something for Twidere. Visit this

**Donation methods**

PayPal & AliPay: "mariotaku.lee#gmail.com".replace("#", "@");
PayPal & AliPay: String.format("%s@%s", "mariotaku.lee", "gmail.com");

PayPal & AliPay: String.format("%s@%s", "pay", "uucky.me");

Bitcoin: 1FHAVAzge7cj1LfCTMfnLL49DgA3mVUCuW

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1333,9 +1333,9 @@ public ResponseList<Place> reverseGeoCode(final GeoQuery query) throws TwitterEx
public QueryResult search(final Query query) throws TwitterException {
final String url = conf.getRestBaseURL() + ENDPOINT_SEARCH_TWEETS;
final String signUrl = conf.getSigningRestBaseURL() + ENDPOINT_SEARCH_TWEETS;
return factory.createQueryResult(get(url, signUrl,
query.asHttpParameterArray(INCLUDE_ENTITIES, INCLUDE_RTS, INCLUDE_REPLY_COUNT,
INCLUDE_DESCENDENT_REPLY_COUNT)), query);
final HttpParameter[] params = query.asHttpParameterArray(INCLUDE_ENTITIES, INCLUDE_RTS, INCLUDE_REPLY_COUNT,
INCLUDE_DESCENDENT_REPLY_COUNT, INCLUDE_MY_RETWEET, INCLUDE_CARDS, CARDS_PLATFORM);
return factory.createQueryResult(get(url, signUrl, params), query);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public interface User extends Comparable<User>, TwitterResponse, Serializable {
*
* @return the profile image url of the user
*/
String getProfileImageURL();
String getProfileImageUrl();

/**
* Returns the profile image url of the user, served over SSL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public String getProfileBannerImageUrl() {
* {@inheritDoc}
*/
@Override
public String getProfileImageURL() {
public String getProfileImageUrl() {
return profileImageUrl;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public boolean getSystemWindowsInsets(Rect insets) {

@Override
public void setControlBarOffset(float offset) {
mTabsContainer.setTranslationY(mTabColumns > 1 ? 1 : getControlBarHeight() * (offset - 1));
mTabsContainer.setTranslationY(mTabColumns > 1 ? 0 : getControlBarHeight() * (offset - 1));
final ViewGroup.LayoutParams lp = mActionsButton.getLayoutParams();
if (lp instanceof MarginLayoutParams) {
mActionsButton.setTranslationY((((MarginLayoutParams) lp).bottomMargin + mActionsButton.getHeight()) * (1 - offset));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public void onStatusClick(StatusViewHolder holder, int position) {
}

@Override
public void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position) {
public void onMediaClick(StatusViewHolder holder, View view, ParcelableMedia media, int position) {

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package org.mariotaku.twidere.adapter;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentActivity;
import android.support.v4.util.Pair;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
Expand All @@ -15,7 +12,6 @@
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
import org.mariotaku.twidere.app.TwidereApplication;
import org.mariotaku.twidere.fragment.support.UserFragment;
import org.mariotaku.twidere.model.ParcelableMedia;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
Expand Down Expand Up @@ -185,14 +181,14 @@ public final void onStatusClick(StatusViewHolder holder, int position) {
}

@Override
public void onMediaClick(StatusViewHolder holder, final ParcelableMedia media, int position) {
public void onMediaClick(StatusViewHolder holder, View view, final ParcelableMedia media, int position) {
if (mStatusAdapterListener == null) return;
mStatusAdapterListener.onMediaClick(holder, media, position);
mStatusAdapterListener.onMediaClick(holder, view, media, position);
}

@Override
public void onUserProfileClick(final StatusViewHolder holder, final int position) {
if (mStatusAdapterListener==null)return;
if (mStatusAdapterListener == null) return;
final ParcelableStatus status = getStatus(position);
if (status == null) return;
mStatusAdapterListener.onUserProfileClick(holder, status, position);
Expand Down Expand Up @@ -301,7 +297,7 @@ public void setShowAccountsColor(boolean showAccountsColor) {
public static interface StatusAdapterListener {
void onGapClick(GapViewHolder holder, int position);

void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position);
void onMediaClick(StatusViewHolder holder, View view, ParcelableMedia media, int position);

void onStatusActionClick(StatusViewHolder holder, int id, int position);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.Loader;
Expand Down Expand Up @@ -242,12 +244,15 @@ public void onGapClick(GapViewHolder holder, int position) {
}

@Override
public void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position) {
public void onMediaClick(StatusViewHolder holder, View view, ParcelableMedia media, int position) {
final AbsStatusesAdapter<Data> adapter = getAdapter();
final ParcelableStatus status = adapter.getStatus(position);
if (status == null) return;
//TODO open media animation
Bundle options = null;
view.buildDrawingCache();
final Bitmap drawingCache = Bitmap.createBitmap(view.getDrawingCache());
final Bundle options = ActivityOptionsCompat.makeThumbnailScaleUpAnimation(view, drawingCache, 0, 0).toBundle();
view.destroyDrawingCache();
Utils.openMedia(getActivity(), status, media, options);
//spice
SpiceProfilingUtil.log(getActivity(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,14 @@ public void onClick(final DialogInterface dialog, final int which) {
if (isPickDirectory() && a instanceof Callback) {
((Callback) a).onFilePicked(getCurrentDirectory());
}
dismiss();
// dismiss();
break;
}
case DialogInterface.BUTTON_NEGATIVE: {
final FragmentActivity a = getActivity();
if (a instanceof Callback) {
((Callback) a).onCancelled(this);
}
break;
}
}
Expand All @@ -100,7 +107,7 @@ public Dialog onCreateDialog(final Bundle savedInstanceState) {
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setAdapter(mAdapter, this);
builder.setTitle(R.string.pick_file);
builder.setNegativeButton(android.R.string.cancel, null);
builder.setNegativeButton(android.R.string.cancel, this);
if (isPickDirectory()) {
builder.setPositiveButton(android.R.string.ok, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.Rect;
Expand All @@ -37,6 +38,7 @@
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
Expand Down Expand Up @@ -107,8 +109,8 @@
import org.mariotaku.twidere.util.TwitterCardUtils;
import org.mariotaku.twidere.util.UserColorNameUtils;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.view.CardMediaContainer.OnMediaClickListener;
import org.mariotaku.twidere.view.CardMediaContainer;
import org.mariotaku.twidere.view.CardMediaContainer.OnMediaClickListener;
import org.mariotaku.twidere.view.ColorLabelRelativeLayout;
import org.mariotaku.twidere.view.ForegroundColorView;
import org.mariotaku.twidere.view.ShapedImageView;
Expand Down Expand Up @@ -292,11 +294,13 @@ public void onGapClick(GapViewHolder holder, int position) {
}

@Override
public void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position) {
public void onMediaClick(StatusViewHolder holder, View view, ParcelableMedia media, int position) {
final ParcelableStatus status = mStatusAdapter.getStatus(position);
if (status == null) return;
//TODO open media animation
Bundle options = null;
view.buildDrawingCache();
final Bitmap drawingCache = Bitmap.createBitmap(view.getDrawingCache());
final Bundle options = ActivityOptionsCompat.makeThumbnailScaleUpAnimation(view, drawingCache, 0, 0).toBundle();
view.destroyDrawingCache();
Utils.openMedia(getActivity(), status, media, options);
SpiceProfilingUtil.log(getActivity(),
status.id + ",Clicked," + status.account_id + "," + status.user_id + "," + status.text_plain.length()
Expand Down Expand Up @@ -380,8 +384,10 @@ public void onUserProfileClick(StatusViewHolder holder, ParcelableStatus status,
public void onMediaClick(View view, ParcelableMedia media, long accountId) {
final ParcelableStatus status = mStatusAdapter.getStatus();
if (status == null) return;
//TODO open media animation
Bundle options = null;
view.buildDrawingCache();
final Bitmap drawingCache = Bitmap.createBitmap(view.getDrawingCache());
final Bundle options = ActivityOptionsCompat.makeThumbnailScaleUpAnimation(view, drawingCache, 0, 0).toBundle();
view.destroyDrawingCache();
Utils.openMediaDirectly(getActivity(), accountId, status, media, status.media, options);
//spice
SpiceProfilingUtil.log(getActivity(),
Expand All @@ -397,18 +403,20 @@ public void onMediaClick(View view, ParcelableMedia media, long accountId) {

private void addConversation(ParcelableStatus status, int position) {
mStatusAdapter.addConversation(status, position);
} @Override
}

private StatusAdapter getAdapter() {
return mStatusAdapter;
}

@Override
public Loader<SingleResponse<ParcelableStatus>> onCreateLoader(final int id, final Bundle args) {
final Bundle fragmentArgs = getArguments();
final long accountId = fragmentArgs.getLong(EXTRA_ACCOUNT_ID, -1);
final long statusId = fragmentArgs.getLong(EXTRA_STATUS_ID, -1);
return new ParcelableStatusLoader(getActivity(), false, fragmentArgs, accountId, statusId);
}

private StatusAdapter getAdapter() {
return mStatusAdapter;
}

private DividerItemDecoration getItemDecoration() {
return mItemDecoration;
}
Expand Down Expand Up @@ -476,29 +484,6 @@ private void loadReplies(ParcelableStatus status) {
}
}
//end
} @Override
public void onLoadFinished(final Loader<SingleResponse<ParcelableStatus>> loader,
final SingleResponse<ParcelableStatus> data) {
if (data.hasData()) {
final long itemId = mStatusAdapter.getItemId(mLayoutManager.findFirstVisibleItemPosition());
final View firstChild = mLayoutManager.getChildAt(0);
final int top = firstChild != null ? firstChild.getTop() : 0;
final ParcelableStatus status = data.getData();
if (mStatusAdapter.setStatus(status)) {
mLayoutManager.scrollToPositionWithOffset(1, 0);
mStatusAdapter.setConversation(null);
mStatusAdapter.setReplies(null);
loadReplies(status);
loadConversation(status);
} else {
final int position = mStatusAdapter.findPositionById(itemId);
mLayoutManager.scrollToPositionWithOffset(position, top);
}
setState(STATE_LOADED);
} else {
//TODO show errors
setState(STATE_ERROR);
}
}

private void restoreReadPosition(@Nullable Pair<Long, Integer> position) {
Expand All @@ -524,6 +509,31 @@ private Pair<Long, Integer> saveReadPosition() {
return new Pair<>(itemId, positionView != null ? positionView.getTop() : -1);
}

@Override
public void onLoadFinished(final Loader<SingleResponse<ParcelableStatus>> loader,
final SingleResponse<ParcelableStatus> data) {
if (data.hasData()) {
final long itemId = mStatusAdapter.getItemId(mLayoutManager.findFirstVisibleItemPosition());
final View firstChild = mLayoutManager.getChildAt(0);
final int top = firstChild != null ? firstChild.getTop() : 0;
final ParcelableStatus status = data.getData();
if (mStatusAdapter.setStatus(status)) {
mLayoutManager.scrollToPositionWithOffset(1, 0);
mStatusAdapter.setConversation(null);
mStatusAdapter.setReplies(null);
loadReplies(status);
loadConversation(status);
} else {
final int position = mStatusAdapter.findPositionById(itemId);
mLayoutManager.scrollToPositionWithOffset(position, top);
}
setState(STATE_LOADED);
} else {
//TODO show errors
setState(STATE_ERROR);
}
}

private void setConversation(List<ParcelableStatus> data) {
final Pair<Long, Integer> readPosition = saveReadPosition();
mStatusAdapter.setConversation(data);
Expand Down Expand Up @@ -865,22 +875,23 @@ private void initViews() {

mediaPreview.setStyle(adapter.getMediaPreviewStyle());

quoteTextView.setTextIsSelectable(true);
textView.setTextIsSelectable(true);

quoteTextView.setMovementMethod(StatusContentMovementMethod.getInstance());
textView.setMovementMethod(StatusContentMovementMethod.getInstance());
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
quoteTextView.setCustomSelectionActionModeCallback(new StatusActionModeCallback(quoteTextView, fragment, activity));
textView.setCustomSelectionActionModeCallback(new StatusActionModeCallback(textView, fragment, activity));
// }

quoteTextView.setCustomSelectionActionModeCallback(new StatusActionModeCallback(quoteTextView, activity));
textView.setCustomSelectionActionModeCallback(new StatusActionModeCallback(textView, activity));
}


private static class StatusActionModeCallback implements Callback {
private final TextView textView;
private final StatusFragment fragment;
private final FragmentActivity activity;

public StatusActionModeCallback(TextView textView, StatusFragment fragment, FragmentActivity activity) {
public StatusActionModeCallback(TextView textView, FragmentActivity activity) {
this.textView = textView;
this.fragment = fragment;
this.activity = activity;
}

Expand Down Expand Up @@ -1388,9 +1399,9 @@ public void onItemMenuClick(ViewHolder holder, View itemView, int position) {
}

@Override
public void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position) {
public void onMediaClick(StatusViewHolder holder, View view, ParcelableMedia media, int position) {
if (mStatusAdapterListener != null) {
mStatusAdapterListener.onMediaClick(holder, media, position);
mStatusAdapterListener.onMediaClick(holder, view, media, position);
}
}

Expand Down Expand Up @@ -1519,14 +1530,11 @@ public void setOrientation(int orientation) {

}


@Override
public void onLoaderReset(final Loader<SingleResponse<ParcelableStatus>> loader) {

}






}
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ public void onPrepareOptionsMenu(final Menu menu) {
}
MenuUtils.setMenuItemAvailability(menu, MENU_MENTION, !isMyself);
MenuUtils.setMenuItemAvailability(menu, R.id.incoming_friendships, isMyself);
MenuUtils.setMenuItemAvailability(menu, R.id.saved_searches, isMyself);
// final MenuItem followItem = menu.findItem(MENU_FOLLOW);
// followItem.setVisible(!isMyself);
// final boolean shouldShowFollowItem = !creatingFriendship && !destroyingFriendship && !isMyself
Expand Down Expand Up @@ -1003,6 +1004,10 @@ public boolean onOptionsItemSelected(final MenuItem item) {
Utils.openUserMentions(getActivity(), user.account_id, user.screen_name);
return true;
}
case R.id.saved_searches: {
Utils.openSavedSearches(getActivity(), user.account_id);
return true;
}
default: {
if (item.getIntent() != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public SettingsImportExportPreference(Context context) {

public SettingsImportExportPreference(Context context, AttributeSet attrs) {
super(context, attrs);
setDialogTitle(null);
setPositiveButtonText(null);
setNegativeButtonText(null);
}
Expand Down
Loading

0 comments on commit d4a8bbb

Please sign in to comment.