removing old card design completely

added santa hat for sakamoto easter egg!
This commit is contained in:
Mariotaku Lee 2014-12-13 23:14:47 +08:00
parent a31cde86a1
commit fface0d9f2
110 changed files with 1434 additions and 2677 deletions

View File

@ -39,6 +39,7 @@ public interface TwidereConstants extends SharedPreferenceConstants, IntentConst
public static final String USER_NICKNAME_PREFERENCES_NAME = "user_nicknames";
public static final String USER_COLOR_PREFERENCES_NAME = "user_colors";
public static final String HOST_MAPPING_PREFERENCES_NAME = "host_mapping";
public static final String MESSAGE_DRAFTS_PREFERENCES_NAME = "message_drafts";
public static final String SHARED_PREFERENCES_NAME = "preferences";
public static final String PERMISSION_PREFERENCES_NAME = "app_permissions";
public static final String SILENT_NOTIFICATIONS_PREFERENCE_NAME = "silent_notifications";

View File

@ -53,7 +53,7 @@ import org.mariotaku.twidere.activity.support.DataImportActivity;
import org.mariotaku.twidere.graphic.EmptyDrawable;
import org.mariotaku.twidere.util.CompareUtils;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.view.holder.ViewHolder;
import org.mariotaku.twidere.view.holder.ListViewHolder;
import java.util.ArrayList;
import java.util.List;
@ -427,7 +427,7 @@ public class SettingsActivity extends BasePreferenceActivity {
}
private static class HeaderViewHolder extends ViewHolder {
private static class HeaderViewHolder extends ListViewHolder {
private final TextView title, summary;
private final ImageView icon;
private final LinearLayout content;

View File

@ -44,9 +44,10 @@ import android.os.Environment;
import android.os.Parcelable;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.util.SparseBooleanArray;
@ -69,7 +70,6 @@ import android.widget.GridView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import android.widget.Toast;
@ -98,6 +98,7 @@ import org.mariotaku.twidere.util.ArrayUtils;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
import org.mariotaku.twidere.util.ContentValuesCreator;
import org.mariotaku.twidere.util.ImageLoaderWrapper;
import org.mariotaku.twidere.util.ImageLoadingHandler;
import org.mariotaku.twidere.util.MathUtils;
import org.mariotaku.twidere.util.ParseUtils;
import org.mariotaku.twidere.util.SharedPreferencesWrapper;
@ -108,7 +109,7 @@ import org.mariotaku.twidere.util.accessor.ViewAccessor;
import org.mariotaku.twidere.view.ComposeSelectAccountButton;
import org.mariotaku.twidere.view.StatusTextCountView;
import org.mariotaku.twidere.view.TwidereMenuBar;
import org.mariotaku.twidere.view.holder.StatusListViewHolder;
import org.mariotaku.twidere.view.holder.StatusViewHolder;
import java.io.File;
import java.io.FileOutputStream;
@ -124,25 +125,20 @@ import java.util.TreeSet;
import static android.os.Environment.getExternalStorageState;
import static android.text.TextUtils.isEmpty;
import static org.mariotaku.twidere.model.ParcelableLocation.isValidLocation;
import static org.mariotaku.twidere.util.ParseUtils.parseString;
import static org.mariotaku.twidere.util.ThemeUtils.getActionBarBackground;
import static org.mariotaku.twidere.util.ThemeUtils.getComposeThemeResource;
import static org.mariotaku.twidere.util.ThemeUtils.getWindowContentOverlayForCompose;
import static org.mariotaku.twidere.util.UserColorNicknameUtils.getUserColor;
import static org.mariotaku.twidere.util.Utils.addIntentToMenu;
import static org.mariotaku.twidere.util.Utils.copyStream;
import static org.mariotaku.twidere.util.Utils.getAccountIds;
import static org.mariotaku.twidere.util.Utils.getAccountName;
import static org.mariotaku.twidere.util.Utils.getAccountScreenName;
import static org.mariotaku.twidere.util.Utils.getCardHighlightColor;
import static org.mariotaku.twidere.util.Utils.getDefaultTextSize;
import static org.mariotaku.twidere.util.Utils.getDisplayName;
import static org.mariotaku.twidere.util.Utils.getImageUploadStatus;
import static org.mariotaku.twidere.util.Utils.getQuoteStatus;
import static org.mariotaku.twidere.util.Utils.getShareStatus;
import static org.mariotaku.twidere.util.Utils.getStatusTypeIconRes;
import static org.mariotaku.twidere.util.Utils.getUserTypeIconRes;
import static org.mariotaku.twidere.util.Utils.showErrorMessage;
import static org.mariotaku.twidere.util.Utils.showMenuItemToast;
@ -1187,7 +1183,8 @@ public class ComposeActivity extends BaseSupportDialogActivity implements TextWa
public static class ViewStatusDialogFragment extends BaseSupportDialogFragment {
private StatusListViewHolder mHolder;
private StatusViewHolder mHolder;
private View mStatusContainer;
public ViewStatusDialogFragment() {
setStyle(STYLE_NO_TITLE, 0);
@ -1202,77 +1199,28 @@ public class ComposeActivity extends BaseSupportDialogActivity implements TextWa
return;
}
final TwidereApplication application = getApplication();
final FragmentActivity activity = getActivity();
final ImageLoaderWrapper loader = application.getImageLoaderWrapper();
final SharedPreferences prefs = getSharedPreferences(SHARED_PREFERENCES_NAME, MODE_PRIVATE);
final ImageLoadingHandler handler = new ImageLoadingHandler(R.id.media_preview_progress);
final AsyncTwitterWrapper twitter = getTwitterWrapper();
final ParcelableStatus status = args.getParcelable(EXTRA_STATUS);
mHolder.setShowAsGap(false);
mHolder.setAccountColorEnabled(true);
mHolder.setTextSize(prefs.getInt(KEY_TEXT_SIZE, getDefaultTextSize(getActivity())));
((View) mHolder.content).setPadding(0, 0, 0, 0);
mHolder.content.setItemBackground(null);
mHolder.content.setItemSelector(null);
mHolder.text.setText(status.text_unescaped);
mHolder.name.setText(status.user_name);
mHolder.screen_name.setText("@" + status.user_screen_name);
mHolder.screen_name.setVisibility(View.VISIBLE);
final String retweeted_by_name = status.retweeted_by_name;
final String retweeted_by_screen_name = status.retweeted_by_screen_name;
final boolean is_my_status = status.account_id == status.user_id;
final boolean hasMedia = status.media != null && status.media.length > 0;
mHolder.setUserColor(getUserColor(getActivity(), status.user_id, true));
mHolder.setHighlightColor(getCardHighlightColor(getResources(), false,
status.is_favorite, status.is_retweet));
mHolder.setIsMyStatus(is_my_status && !prefs.getBoolean(KEY_INDICATE_MY_STATUS, true));
mHolder.name.setCompoundDrawablesWithIntrinsicBounds(0, 0,
getUserTypeIconRes(status.user_is_verified, status.user_is_protected), 0);
mHolder.time.setTime(status.timestamp);
final int type_icon = getStatusTypeIconRes(status.is_favorite, isValidLocation(status.location), hasMedia,
status.is_possibly_sensitive);
mHolder.time.setCompoundDrawablesWithIntrinsicBounds(0, 0, type_icon, 0);
mHolder.reply_retweet_status
.setVisibility(status.in_reply_to_status_id != -1 || status.is_retweet ? View.VISIBLE : View.GONE);
if (status.is_retweet && !TextUtils.isEmpty(retweeted_by_name)
&& !TextUtils.isEmpty(retweeted_by_screen_name)) {
if (!prefs.getBoolean(KEY_NAME_FIRST, true)) {
mHolder.reply_retweet_status.setText(status.retweet_count > 1 ? getString(
R.string.retweeted_by_name_with_count, retweeted_by_screen_name, status.retweet_count - 1)
: getString(R.string.retweeted_by_name, retweeted_by_screen_name));
} else {
mHolder.reply_retweet_status.setText(status.retweet_count > 1 ? getString(
R.string.retweeted_by_name_with_count, retweeted_by_name, status.retweet_count - 1) : getString(
R.string.retweeted_by_name, retweeted_by_name));
}
mHolder.reply_retweet_status.setText(status.retweet_count > 1 ? getString(
R.string.retweeted_by_name_with_count, retweeted_by_name, status.retweet_count - 1) : getString(
R.string.retweeted_by_name, retweeted_by_name));
mHolder.reply_retweet_status.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_indicator_retweet,
0, 0, 0);
} else if (status.in_reply_to_status_id > 0 && !TextUtils.isEmpty(status.in_reply_to_screen_name)) {
mHolder.reply_retweet_status.setText(getString(R.string.in_reply_to_name, status.in_reply_to_screen_name));
mHolder.reply_retweet_status.setCompoundDrawablesWithIntrinsicBounds(
R.drawable.ic_indicator_conversation, 0, 0, 0);
}
if (prefs.getBoolean(KEY_DISPLAY_PROFILE_IMAGE, true)) {
loader.displayProfileImage(mHolder.my_profile_image, status.user_profile_image_url);
loader.displayProfileImage(mHolder.profile_image, status.user_profile_image_url);
} else {
mHolder.profile_image.setVisibility(View.GONE);
mHolder.my_profile_image.setVisibility(View.GONE);
}
mHolder.image_preview_container.setVisibility(View.GONE);
mHolder.displayStatus(activity, loader, handler, twitter, status);
mStatusContainer.findViewById(R.id.item_menu).setVisibility(View.GONE);
mStatusContainer.findViewById(R.id.action_buttons).setVisibility(View.GONE);
mStatusContainer.findViewById(R.id.reply_retweet_status).setVisibility(View.GONE);
}
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup parent, final Bundle savedInstanceState) {
final ScrollView view = (ScrollView) inflater.inflate(R.layout.dialog_scrollable_status, parent, false);
mHolder = new StatusListViewHolder(view.getChildAt(0));
return view;
return inflater.inflate(R.layout.dialog_scrollable_status, parent, false);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mStatusContainer = view.findViewById(R.id.status_container);
mHolder = new StatusViewHolder(view);
}
}
private static class AccountSelectorAdapter extends BaseArrayAdapter<ParcelableAccount> {

View File

@ -26,9 +26,13 @@ import android.graphics.Rect;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.ListFragment;
import android.support.v4.app.SharedElementCallback;
import android.support.v4.view.WindowCompat;
import android.support.v4.view.WindowInsetsCompat;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
@ -51,6 +55,8 @@ import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.view.TintedStatusFrameLayout;
import java.util.List;
import static org.mariotaku.twidere.util.Utils.createFragmentForIntent;
import static org.mariotaku.twidere.util.Utils.matchLinkId;

View File

@ -54,6 +54,11 @@ public class AccountsSpinnerAdapter extends ArrayAdapter<ParcelableAccount> {
addAll(accounts);
}
@Override
public long getItemId(int position) {
return getItem(position).account_id;
}
@Override
public View getDropDownView(final int position, final View convertView, final ViewGroup parent) {
final View view = super.getDropDownView(position, convertView, parent);

View File

@ -47,10 +47,7 @@ public abstract class BaseParcelableActivitiesAdapter extends BaseArrayAdapter<P
private final MultiSelectManager mMultiSelectManager;
private final ImageLoaderWrapper mImageLoader;
private boolean mShowAbsoluteTime, mAnimationEnabled;
private int mMaxAnimationPosition;
private MenuButtonClickListener mListener;
private boolean mShowAbsoluteTime;
public BaseParcelableActivitiesAdapter(final Context context) {
this(context, isCompactCards(context));
@ -113,28 +110,12 @@ public abstract class BaseParcelableActivitiesAdapter extends BaseArrayAdapter<P
notifyDataSetChanged();
}
@Override
public void setAnimationEnabled(final boolean anim) {
if (mAnimationEnabled == anim) return;
mAnimationEnabled = anim;
}
public void setData(final List<ParcelableActivity> data) {
clear();
if (data == null) return;
addAll(data);
}
@Override
public void setMaxAnimationPosition(final int position) {
mMaxAnimationPosition = position;
}
@Override
public void setMenuButtonClickListener(final MenuButtonClickListener listener) {
mListener = listener;
}
public void setShowAbsoluteTime(final boolean show) {
if (show != mShowAbsoluteTime) {
mShowAbsoluteTime = show;

View File

@ -157,16 +157,5 @@ public class DirectMessageConversationEntriesAdapter extends BaseCursorAdapter i
}
}
@Override
public void setAnimationEnabled(final boolean anim) {
}
@Override
public void setMaxAnimationPosition(final int position) {
}
@Override
public void setMenuButtonClickListener(final MenuButtonClickListener listener) {
}
}

View File

@ -50,12 +50,8 @@ public class DirectMessagesConversationAdapter extends BaseCursorAdapter impleme
private final ImageLoaderWrapper mImageLoader;
private final Context mContext;
private final MultiSelectManager mMultiSelectManager;
private MenuButtonClickListener mListener;
private final ImageLoadingHandler mImageLoadingHandler;
private boolean mAnimationEnabled = true;
private int mMaxAnimationPosition;
private ParcelableDirectMessage.CursorIndices mIndices;
public DirectMessagesConversationAdapter(final Context context) {
@ -85,12 +81,6 @@ public class DirectMessagesConversationAdapter extends BaseCursorAdapter impleme
getLinkify().applyAllLinks(holder.text, accountId, false);
holder.text.setMovementMethod(null);
holder.time.setText(formatToLongTimeString(mContext, timestamp));
if (position > mMaxAnimationPosition) {
if (mAnimationEnabled) {
view.startAnimation(holder.item_animation);
}
mMaxAnimationPosition = position;
}
if (firstMedia == null) {
mImageLoader.cancelDisplayTask(holder.media_preview);
@ -155,11 +145,6 @@ public class DirectMessagesConversationAdapter extends BaseCursorAdapter impleme
}
}
@Override
public void setAnimationEnabled(final boolean anim) {
mAnimationEnabled = anim;
}
@Override
public void setDisplayImagePreview(final boolean display) {
// Images in DM are always enabled
@ -171,16 +156,6 @@ public class DirectMessagesConversationAdapter extends BaseCursorAdapter impleme
mImagePreviewScaleType = scaleType;
}
@Override
public void setMaxAnimationPosition(final int position) {
mMaxAnimationPosition = position;
}
@Override
public void setMenuButtonClickListener(final MenuButtonClickListener listener) {
mListener = listener;
}
@Override
public Cursor swapCursor(final Cursor cursor) {
if (cursor != null) {

View File

@ -33,8 +33,7 @@ import org.mariotaku.twidere.model.ParcelableUserList;
import org.mariotaku.twidere.util.ImageLoaderWrapper;
import org.mariotaku.twidere.util.MultiSelectManager;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.view.holder.UserListViewHolder;
import org.mariotaku.twidere.view.iface.ICardItemView.OnOverflowIconClickListener;
import org.mariotaku.twidere.view.holder.UserListListViewHolder;
import java.util.List;
import java.util.Locale;
@ -45,18 +44,13 @@ import static org.mariotaku.twidere.util.Utils.getLocalizedNumber;
import static org.mariotaku.twidere.util.Utils.openUserProfile;
public class ParcelableUserListsAdapter extends BaseArrayAdapter<ParcelableUserList> implements IBaseCardAdapter,
OnClickListener, OnOverflowIconClickListener {
OnClickListener {
private final Context mContext;
private final ImageLoaderWrapper mImageLoader;
private final MultiSelectManager mMultiSelectManager;
private final Locale mLocale;
private MenuButtonClickListener mListener;
private boolean mAnimationEnabled;
private int mMaxAnimationPosition;
public ParcelableUserListsAdapter(final Context context) {
this(context, Utils.isCompactCards(context));
}
@ -84,13 +78,13 @@ public class ParcelableUserListsAdapter extends BaseArrayAdapter<ParcelableUserL
public View getView(final int position, final View convertView, final ViewGroup parent) {
final View view = super.getView(position, convertView, parent);
final Object tag = view.getTag();
final UserListViewHolder holder;
if (tag instanceof UserListViewHolder) {
holder = (UserListViewHolder) tag;
final UserListListViewHolder holder;
if (tag instanceof UserListListViewHolder) {
holder = (UserListListViewHolder) tag;
} else {
holder = new UserListViewHolder(view);
holder = new UserListListViewHolder(view);
holder.profile_image.setOnClickListener(this);
holder.content.setOnOverflowIconClickListener(this);
// holder.content.setOnOverflowIconClickListener(this);
view.setTag(holder);
}
@ -113,12 +107,6 @@ public class ParcelableUserListsAdapter extends BaseArrayAdapter<ParcelableUserL
mImageLoader.cancelDisplayTask(holder.profile_image);
}
holder.profile_image.setTag(position);
if (position > mMaxAnimationPosition) {
if (mAnimationEnabled) {
view.startAnimation(holder.item_animation);
}
mMaxAnimationPosition = position;
}
return view;
}
@ -140,24 +128,6 @@ public class ParcelableUserListsAdapter extends BaseArrayAdapter<ParcelableUserL
}
}
@Override
public void onOverflowIconClick(final View view) {
if (mMultiSelectManager.isActive()) return;
final Object tag = view.getTag();
if (tag instanceof UserListViewHolder) {
final UserListViewHolder holder = (UserListViewHolder) tag;
final int position = holder.position;
if (position == -1 || mListener == null) return;
mListener.onMenuButtonClick(view, position, getItemId(position));
}
}
@Override
public void setAnimationEnabled(final boolean anim) {
if (mAnimationEnabled == anim) return;
mAnimationEnabled = anim;
}
public void setData(final List<ParcelableUserList> data, final boolean clear_old) {
if (clear_old) {
clear();
@ -170,15 +140,6 @@ public class ParcelableUserListsAdapter extends BaseArrayAdapter<ParcelableUserL
}
}
@Override
public void setMaxAnimationPosition(final int position) {
mMaxAnimationPosition = position;
}
@Override
public void setMenuButtonClickListener(final MenuButtonClickListener listener) {
mListener = listener;
}
private static int getItemResource(final boolean compactCards) {
return compactCards ? R.layout.card_item_user_list_compact : R.layout.card_item_user_list;

View File

@ -31,8 +31,7 @@ import org.mariotaku.twidere.model.ParcelableUser;
import org.mariotaku.twidere.util.ImageLoaderWrapper;
import org.mariotaku.twidere.util.MultiSelectManager;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.view.holder.UserViewHolder;
import org.mariotaku.twidere.view.iface.ICardItemView.OnOverflowIconClickListener;
import org.mariotaku.twidere.view.holder.UserListViewHolder;
import java.util.List;
import java.util.Locale;
@ -44,19 +43,14 @@ import static org.mariotaku.twidere.util.Utils.getAccountColor;
import static org.mariotaku.twidere.util.Utils.getLocalizedNumber;
import static org.mariotaku.twidere.util.Utils.getUserTypeIconRes;
public class ParcelableUsersAdapter extends BaseArrayAdapter<ParcelableUser> implements IBaseCardAdapter,
OnOverflowIconClickListener {
public class ParcelableUsersAdapter extends BaseArrayAdapter<ParcelableUser> implements IBaseCardAdapter {
private final ImageLoaderWrapper mProfileImageLoader;
private final MultiSelectManager mMultiSelectManager;
private final Context mContext;
private MenuButtonClickListener mListener;
private final Locale mLocale;
private boolean mAnimationEnabled;
private int mMaxAnimationPosition;
public ParcelableUsersAdapter(final Context context) {
this(context, Utils.isCompactCards(context));
}
@ -80,12 +74,12 @@ public class ParcelableUsersAdapter extends BaseArrayAdapter<ParcelableUser> imp
public View getView(final int position, final View convertView, final ViewGroup parent) {
final View view = super.getView(position, convertView, parent);
final Object tag = view.getTag();
final UserViewHolder holder;
if (tag instanceof UserViewHolder) {
holder = (UserViewHolder) tag;
final UserListViewHolder holder;
if (tag instanceof UserListViewHolder) {
holder = (UserListViewHolder) tag;
} else {
holder = new UserViewHolder(view);
holder.content.setOnOverflowIconClickListener(this);
holder = new UserListViewHolder(view);
// holder.content.setOnOverflowIconClickListener(this);
view.setTag(holder);
}
@ -104,8 +98,12 @@ public class ParcelableUsersAdapter extends BaseArrayAdapter<ParcelableUser> imp
holder.setUserColor(getUserColor(mContext, user.id));
holder.setTextSize(getTextSize());
holder.name.setCompoundDrawablesWithIntrinsicBounds(0, 0,
getUserTypeIconRes(user.is_verified, user.is_protected), 0);
final int userTypeRes = getUserTypeIconRes(user.is_verified, user.is_protected);
if (userTypeRes != 0) {
holder.profile_type.setImageResource(userTypeRes);
} else {
holder.profile_type.setImageDrawable(null);
}
final String nick = getUserNickname(mContext, user.id);
holder.name.setText(TextUtils.isEmpty(nick) ? user.name : isNicknameOnly() ? nick : mContext.getString(
R.string.name_with_nickname, user.name, nick));
@ -123,32 +121,9 @@ public class ParcelableUsersAdapter extends BaseArrayAdapter<ParcelableUser> imp
if (isDisplayProfileImage()) {
mProfileImageLoader.displayProfileImage(holder.profile_image, user.profile_image_url);
}
if (position > mMaxAnimationPosition) {
if (mAnimationEnabled) {
view.startAnimation(holder.item_animation);
}
mMaxAnimationPosition = position;
}
return view;
}
@Override
public void onOverflowIconClick(final View view) {
if (mMultiSelectManager.isActive()) return;
final Object tag = view.getTag();
if (tag instanceof UserViewHolder) {
final UserViewHolder holder = (UserViewHolder) tag;
final int position = holder.position;
if (position == -1 || mListener == null) return;
mListener.onMenuButtonClick(view, position, getItemId(position));
}
}
@Override
public void setAnimationEnabled(final boolean anim) {
if (mAnimationEnabled == anim) return;
mAnimationEnabled = anim;
}
public void setData(final List<ParcelableUser> data) {
setData(data, false);
@ -166,15 +141,6 @@ public class ParcelableUsersAdapter extends BaseArrayAdapter<ParcelableUser> imp
}
}
@Override
public void setMaxAnimationPosition(final int position) {
mMaxAnimationPosition = position;
}
@Override
public void setMenuButtonClickListener(final MenuButtonClickListener listener) {
mListener = listener;
}
private static int getItemResource(final boolean compactCards) {
return compactCards ? R.layout.card_item_user_compact : R.layout.card_item_user;

View File

@ -40,8 +40,10 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration {
private Drawable mDivider;
private int mOrientation;
private Rect mPadding;
public DividerItemDecoration(Context context, int orientation) {
mPadding = new Rect();
final TypedArray a = context.obtainStyledAttributes(ATTRS);
mDivider = a.getDrawable(0);
a.recycle();
@ -64,6 +66,10 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration {
}
}
public void setPadding(int left, int top, int right, int bottom) {
mPadding.set(left, top, right, bottom);
}
public void drawVertical(Canvas c, RecyclerView parent) {
final int left = parent.getPaddingLeft();
final int right = parent.getWidth() - parent.getPaddingRight();
@ -76,7 +82,8 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration {
final int top = child.getBottom() + params.bottomMargin +
Math.round(ViewCompat.getTranslationY(child));
final int bottom = top + mDivider.getIntrinsicHeight();
mDivider.setBounds(left, top, right, bottom);
mDivider.setBounds(left + mPadding.left, top + mPadding.top, right - mPadding.right,
bottom - mPadding.bottom);
mDivider.draw(c);
}
}
@ -93,7 +100,8 @@ public class DividerItemDecoration extends RecyclerView.ItemDecoration {
final int left = child.getRight() + params.rightMargin +
Math.round(ViewCompat.getTranslationX(child));
final int right = left + mDivider.getIntrinsicHeight();
mDivider.setBounds(left, top, right, bottom);
mDivider.setBounds(left + mPadding.left, top + mPadding.top, right - mPadding.right,
bottom - mPadding.bottom);
mDivider.draw(c);
}
}

View File

@ -23,12 +23,6 @@ import android.view.View;
public interface IBaseCardAdapter extends IBaseAdapter {
public void setAnimationEnabled(boolean anim);
public void setMaxAnimationPosition(int position);
public void setMenuButtonClickListener(MenuButtonClickListener listener);
public static interface MenuButtonClickListener {
void onMenuButtonClick(View button, int position, long id);
}

View File

@ -129,7 +129,6 @@ abstract class BaseUserListsListFragment extends BasePullToRefreshListFragment i
// }
// mAccountId = account_id;
setListAdapter(mAdapter);
mAdapter.setMenuButtonClickListener(this);
getLoaderManager().initLoader(0, getArguments(), this);
setListShown(false);
setRefreshMode(RefreshMode.NONE);

View File

@ -103,7 +103,6 @@ abstract class BaseUsersListFragment extends BasePullToRefreshListFragment imple
super.onActivityCreated(savedInstanceState);
mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
mAdapter = new ParcelableUsersAdapter(getActivity());
mAdapter.setMenuButtonClickListener(this);
mMultiSelectManager = getMultiSelectManager();
mListView = getListView();
mListView.setFastScrollEnabled(mPreferences.getBoolean(KEY_FAST_SCROLL_THUMB, false));

View File

@ -45,6 +45,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.BaseAdapter;
import android.widget.EditText;
@ -68,6 +69,7 @@ import org.mariotaku.twidere.adapter.iface.IBaseCardAdapter.MenuButtonClickListe
import org.mariotaku.twidere.app.TwidereApplication;
import org.mariotaku.twidere.loader.support.UserSearchLoader;
import org.mariotaku.twidere.model.ParcelableAccount;
import org.mariotaku.twidere.model.ParcelableAccount.ParcelableCredentials;
import org.mariotaku.twidere.model.ParcelableDirectMessage;
import org.mariotaku.twidere.model.ParcelableUser;
import org.mariotaku.twidere.provider.TweetStore;
@ -87,7 +89,6 @@ import org.mariotaku.twidere.view.iface.IColorLabelView;
import java.util.List;
import java.util.Locale;
import static android.text.TextUtils.isEmpty;
import static org.mariotaku.twidere.util.Utils.buildDirectMessageConversationUri;
import static org.mariotaku.twidere.util.Utils.configBaseCardAdapter;
import static org.mariotaku.twidere.util.Utils.showOkMessage;
@ -101,6 +102,7 @@ public class DirectMessagesConversationFragment extends BaseSupportFragment impl
private TwidereValidator mValidator;
private AsyncTwitterWrapper mTwitterWrapper;
private SharedPreferences mPreferences;
private SharedPreferences mMessageDrafts;
private ListView mMessagesListView, mUsersSearchList;
private EditText mEditText;
@ -117,7 +119,6 @@ public class DirectMessagesConversationFragment extends BaseSupportFragment impl
private PopupMenu mPopupMenu;
private ParcelableDirectMessage mSelectedDirectMessage;
private long mAccountId, mRecipientId;
private boolean mLoaderInitialized;
private boolean mLoadMoreAutomatically;
private String mImageUri;
@ -127,7 +128,7 @@ public class DirectMessagesConversationFragment extends BaseSupportFragment impl
private DirectMessagesConversationAdapter mAdapter;
private SimpleParcelableUsersAdapter mUsersSearchAdapter;
private ParcelableAccount mSender;
private ParcelableCredentials mAccount;
private ParcelableUser mRecipient;
private ImageLoaderWrapper mImageLoader;
@ -178,30 +179,29 @@ public class DirectMessagesConversationFragment extends BaseSupportFragment impl
setHasOptionsMenu(true);
final FragmentActivity activity = getActivity();
final ActionBar actionBar = activity.getActionBar();
if (actionBar != null) {
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(R.layout.actionbar_custom_view_message_user_picker);
final View actionBarView = actionBar.getCustomView();
mAccountSpinner = (Spinner) actionBarView.findViewById(R.id.account_spinner);
mUserQuery = (EditText) actionBarView.findViewById(R.id.user_query);
mQueryButton = actionBarView.findViewById(R.id.query_button);
final List<ParcelableAccount> accounts = ParcelableAccount.getAccountsList(activity, false);
final AccountsSpinnerAdapter adapter = new AccountsSpinnerAdapter(actionBar.getThemedContext(), R.layout.spinner_item_account_icon);
adapter.setDropDownViewResource(R.layout.list_item_user);
adapter.addAll(accounts);
mAccountSpinner.setAdapter(adapter);
mAccountSpinner.setOnItemSelectedListener(this);
mQueryButton.setOnClickListener(this);
}
if (actionBar == null) throw new NullPointerException();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(R.layout.actionbar_custom_view_message_user_picker);
final View actionBarView = actionBar.getCustomView();
mAccountSpinner = (Spinner) actionBarView.findViewById(R.id.account_spinner);
mUserQuery = (EditText) actionBarView.findViewById(R.id.user_query);
mQueryButton = actionBarView.findViewById(R.id.query_button);
final List<ParcelableCredentials> accounts = ParcelableCredentials.getCredentialsList(activity, false);
final AccountsSpinnerAdapter accountsSpinnerAdapter = new AccountsSpinnerAdapter(actionBar.getThemedContext(), R.layout.spinner_item_account_icon);
accountsSpinnerAdapter.setDropDownViewResource(R.layout.list_item_user);
accountsSpinnerAdapter.addAll(accounts);
mAccountSpinner.setAdapter(accountsSpinnerAdapter);
mAccountSpinner.setOnItemSelectedListener(this);
mQueryButton.setOnClickListener(this);
mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
mMessageDrafts = getSharedPreferences(MESSAGE_DRAFTS_PREFERENCES_NAME, Context.MODE_PRIVATE);
mImageLoader = TwidereApplication.getInstance(getActivity()).getImageLoaderWrapper();
mTwitterWrapper = getTwitterWrapper();
mValidator = new TwidereValidator(getActivity());
mLocale = getResources().getConfiguration().locale;
mAdapter = new DirectMessagesConversationAdapter(getActivity());
mMessagesListView.setAdapter(mAdapter);
mAdapter.setMenuButtonClickListener(this);
mMessagesListView.setDivider(null);
mMessagesListView.setSelector(android.R.color.transparent);
mMessagesListView.setFastScrollEnabled(mPreferences.getBoolean(KEY_FAST_SCROLL_THUMB, false));
@ -210,6 +210,14 @@ public class DirectMessagesConversationFragment extends BaseSupportFragment impl
mUsersSearchAdapter = new SimpleParcelableUsersAdapter(activity);
mUsersSearchList.setAdapter(mUsersSearchAdapter);
mUsersSearchList.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
final ParcelableCredentials account = (ParcelableCredentials) mAccountSpinner.getSelectedItem();
showConversation(account, mUsersSearchAdapter.getItem(position));
updateProfileImage();
}
});
if (mPreferences.getBoolean(KEY_QUICK_SEND, false)) {
mEditText.setOnEditorActionListener(this);
@ -221,18 +229,38 @@ public class DirectMessagesConversationFragment extends BaseSupportFragment impl
mAddImageButton.setOnClickListener(this);
mSendButton.setEnabled(false);
if (savedInstanceState != null) {
final long accountId = savedInstanceState.getLong(EXTRA_ACCOUNT_ID, -1);
final long recipientId = savedInstanceState.getLong(EXTRA_RECIPIENT_ID, -1);
showConversation(accountId, recipientId);
final ParcelableCredentials account = savedInstanceState.getParcelable(EXTRA_ACCOUNT);
final ParcelableUser recipient = savedInstanceState.getParcelable(EXTRA_USER);
showConversation(account, recipient);
mEditText.setText(savedInstanceState.getString(EXTRA_TEXT));
mImageUri = savedInstanceState.getString(EXTRA_IMAGE_URI);
} else {
final Bundle args = getArguments();
final long accountId = args != null ? args.getLong(EXTRA_ACCOUNT_ID, -1) : -1;
final long recipientId = args != null ? args.getLong(EXTRA_RECIPIENT_ID, -1) : -1;
showConversation(accountId, recipientId);
final ParcelableCredentials account;
final ParcelableUser recipient;
if (args != null) {
if (args.containsKey(EXTRA_ACCOUNT)) {
account = args.getParcelable(EXTRA_ACCOUNT);
recipient = args.getParcelable(EXTRA_USER);
} else if (args.containsKey(EXTRA_ACCOUNT_ID)) {
final long accountId = args.getLong(EXTRA_ACCOUNT_ID, -1);
final long userId = args.getLong(EXTRA_RECIPIENT_ID, -1);
final int accountPos = accountsSpinnerAdapter.findItemPosition(accountId);
account = accountPos < 0 ? ParcelableAccount.getCredentials(activity, accountId)
: (ParcelableCredentials) accountsSpinnerAdapter.getItem(accountPos);
recipient = Utils.getUserForConversation(activity, accountId, userId);
} else {
account = null;
recipient = null;
}
showConversation(account, recipient);
if (account != null && recipient != null) {
final String key = getDraftsTextKey(account.account_id, recipient.id);
mEditText.setText(mMessageDrafts.getString(key, null));
}
}
}
final boolean isValid = mAccountId > 0 && mRecipientId > 0;
final boolean isValid = mAccount != null && mRecipient != null;
mConversationContainer.setVisibility(isValid ? View.VISIBLE : View.GONE);
mRecipientSelectorContainer.setVisibility(isValid ? View.GONE : View.VISIBLE);
@ -240,22 +268,13 @@ public class DirectMessagesConversationFragment extends BaseSupportFragment impl
mUsersSearchProgress.setVisibility(View.GONE);
}
private String getDraftsTextKey(long accountId, long userId) {
return String.format(Locale.ROOT, "text_%d_to_%d", accountId, userId);
}
@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
switch (requestCode) {
case REQUEST_SELECT_USER: {
if (resultCode != Activity.RESULT_OK || !data.hasExtra(EXTRA_USER)) {
break;
}
final ParcelableUser user = data.getParcelableExtra(EXTRA_USER);
if (user != null && mAccountId > 0) {
mRecipientId = user.id;
mRecipient = user;
showConversation(mAccountId, mRecipientId);
updateProfileImage();
}
break;
}
case REQUEST_PICK_IMAGE: {
if (resultCode != Activity.RESULT_OK || data.getDataString() == null) {
break;
@ -280,14 +299,20 @@ public class DirectMessagesConversationFragment extends BaseSupportFragment impl
return;
}
mProfileImageContainer.setVisibility(mRecipient != null ? View.VISIBLE : View.GONE);
if (mSender != null && mRecipient != null) {
mImageLoader.displayProfileImage(mSenderProfileImageView, mSender.profile_image_url);
if (mAccount != null && mRecipient != null) {
mImageLoader.displayProfileImage(mSenderProfileImageView, mAccount.profile_image_url);
mImageLoader.displayProfileImage(mRecipientProfileImageView, mRecipient.profile_image_url);
mProfileImageContainer.drawEnd(mSender.color);
mProfileImageContainer.drawEnd(mAccount.color);
} else {
mImageLoader.cancelDisplayTask(mSenderProfileImageView);
mImageLoader.cancelDisplayTask(mRecipientProfileImageView);
}
final FragmentActivity activity = getActivity();
if (mRecipient != null) {
activity.setTitle(Utils.getDisplayName(activity, mRecipient));
} else {
activity.setTitle(R.string.direct_messages);
}
}
@Override
@ -391,10 +416,9 @@ public class DirectMessagesConversationFragment extends BaseSupportFragment impl
@Override
public void onItemSelected(final AdapterView<?> parent, final View view, final int pos, final long id) {
final ParcelableAccount account = (ParcelableAccount) mAccountSpinner.getSelectedItem();
final ParcelableCredentials account = (ParcelableCredentials) mAccountSpinner.getSelectedItem();
if (account != null) {
mAccountId = account.account_id;
mSender = account;
mAccount = account;
updateProfileImage();
}
}
@ -491,8 +515,8 @@ public class DirectMessagesConversationFragment extends BaseSupportFragment impl
if (mEditText != null) {
outState.putCharSequence(EXTRA_TEXT, mEditText.getText());
}
outState.putLong(EXTRA_ACCOUNT_ID, mAccountId);
outState.putLong(EXTRA_RECIPIENT_ID, mRecipientId);
outState.putParcelable(EXTRA_ACCOUNT, mAccount);
outState.putParcelable(EXTRA_USER, mRecipient);
outState.putString(EXTRA_IMAGE_URI, mImageUri);
}
@ -511,6 +535,15 @@ public class DirectMessagesConversationFragment extends BaseSupportFragment impl
if (mPopupMenu != null) {
mPopupMenu.dismiss();
}
final ParcelableCredentials account = mAccount;
final ParcelableUser recipient = mRecipient;
if (account != null && recipient != null) {
final String key = getDraftsTextKey(account.account_id, recipient.id);
final SharedPreferences.Editor editor = mMessageDrafts.edit();
editor.putString(key, ParseUtils.parseString(mEditText.getText()));
editor.apply();
}
super.onStop();
}
@ -544,16 +577,14 @@ public class DirectMessagesConversationFragment extends BaseSupportFragment impl
// return true;
// }
public void showConversation(final long accountId, final long recipientId) {
mAccountId = accountId;
mRecipientId = recipientId;
final Context context = getActivity();
mSender = ParcelableAccount.getAccount(context, accountId);
mRecipient = Utils.getUserForConversation(context, accountId, recipientId);
public void showConversation(final ParcelableCredentials account, final ParcelableUser recipient) {
mAccount = account;
mRecipient = recipient;
if (account == null || recipient == null) return;
final LoaderManager lm = getLoaderManager();
final Bundle args = new Bundle();
args.putLong(EXTRA_ACCOUNT_ID, accountId);
args.putLong(EXTRA_RECIPIENT_ID, recipientId);
args.putLong(EXTRA_ACCOUNT_ID, account.account_id);
args.putLong(EXTRA_RECIPIENT_ID, recipient.id);
if (mLoaderInitialized) {
lm.restartLoader(0, args, this);
} else {
@ -612,12 +643,13 @@ public class DirectMessagesConversationFragment extends BaseSupportFragment impl
// }
private void sendDirectMessage() {
final Editable text = mEditText.getText();
if (isEmpty(text) || mAccountId <= 0 || mRecipientId <= 0) return;
final String message = text.toString();
final ParcelableCredentials account = mAccount;
final ParcelableUser recipient = mRecipient;
if (mAccount == null || mRecipient == null) return;
final String message = mEditText.getText().toString();
if (mValidator.isValidTweet(message)) {
mTwitterWrapper.sendDirectMessageAsync(mAccountId, mRecipientId, message, mImageUri);
text.clear();
mTwitterWrapper.sendDirectMessageAsync(account.account_id, recipient.id, message, mImageUri);
mEditText.setText(null);
mImageUri = null;
updateAddImageButton();
}

View File

@ -6,7 +6,7 @@ import android.view.MenuInflater;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.model.ParcelableAccount;
import org.mariotaku.twidere.model.ParcelableAccount.ParcelableAccountWithCredentials;
import org.mariotaku.twidere.model.ParcelableAccount.ParcelableCredentials;
import org.mariotaku.twidere.model.ParcelableUser;
public class IncomingFriendshipsMenuDialogFragment extends UserMenuDialogFragment {
@ -14,8 +14,8 @@ public class IncomingFriendshipsMenuDialogFragment extends UserMenuDialogFragmen
@Override
protected void onPrepareItemMenu(final Menu menu, final ParcelableUser user) {
final Context context = getThemedContext();
final ParcelableAccountWithCredentials account = ParcelableAccount.getAccountWithCredentials(context, user.account_id);
if (ParcelableAccountWithCredentials.isOfficialCredentials(context, account)) {
final ParcelableCredentials account = ParcelableAccount.getCredentials(context, user.account_id);
if (ParcelableCredentials.isOfficialCredentials(context, account)) {
final MenuInflater inflater = new MenuInflater(context);
inflater.inflate(R.menu.action_incoming_friendship, menu);
}

View File

@ -54,7 +54,7 @@ public abstract class ParcelableStatusesFragment extends AbsStatusesFragment<Lis
if (status.id == statusId || status.retweet_id > 0 && status.retweet_id == statusId) {
dataToRemove.add(status);
} else if (status.my_retweet_id == statusId) {
data.set(i, new ParcelableStatus(status, -1));
data.set(i, new ParcelableStatus(status, -1, status.retweet_count - 1));
}
}
data.removeAll(dataToRemove);
@ -157,7 +157,7 @@ public abstract class ParcelableStatusesFragment extends AbsStatusesFragment<Lis
for (int i = 0, j = data.size(); i < j; i++) {
final ParcelableStatus orig = data.get(i);
if (orig.account_id == status.account_id && orig.id == status.retweet_id) {
data.set(i, new ParcelableStatus(orig, status.id));
data.set(i, new ParcelableStatus(orig, status.my_retweet_id, status.retweet_count));
}
}
setAdapterData(data);

View File

@ -65,7 +65,7 @@ import org.mariotaku.twidere.loader.ParcelableStatusLoader;
import org.mariotaku.twidere.loader.support.StatusRepliesLoader;
import org.mariotaku.twidere.model.ListResponse;
import org.mariotaku.twidere.model.ParcelableAccount;
import org.mariotaku.twidere.model.ParcelableAccount.ParcelableAccountWithCredentials;
import org.mariotaku.twidere.model.ParcelableAccount.ParcelableCredentials;
import org.mariotaku.twidere.model.ParcelableMedia;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.model.SingleResponse;
@ -348,7 +348,7 @@ public class StatusFragment extends BaseSupportFragment
private final int mTextSize;
private ParcelableStatus mStatus;
private ParcelableAccountWithCredentials mStatusAccount;
private ParcelableCredentials mStatusAccount;
private List<ParcelableStatus> mConversation, mReplies;
private boolean mDetailMediaExpanded;
@ -410,7 +410,7 @@ public class StatusFragment extends BaseSupportFragment
}
}
public ParcelableAccountWithCredentials getStatusAccount() {
public ParcelableCredentials getStatusAccount() {
return mStatusAccount;
}
@ -451,7 +451,7 @@ public class StatusFragment extends BaseSupportFragment
final ParcelableStatus old = mStatus;
mStatus = status;
if (status != null) {
mStatusAccount = ParcelableAccount.getAccountWithCredentials(mContext, status.account_id);
mStatusAccount = ParcelableAccount.getCredentials(mContext, status.account_id);
} else {
mStatusAccount = null;
}
@ -796,9 +796,9 @@ public class StatusFragment extends BaseSupportFragment
break;
}
case MENU_TRANSLATE: {
final ParcelableAccountWithCredentials account
= ParcelableAccount.getAccountWithCredentials(activity, status.account_id);
if (ParcelableAccountWithCredentials.isOfficialCredentials(activity, account)) {
final ParcelableCredentials account
= ParcelableAccount.getCredentials(activity, status.account_id);
if (ParcelableCredentials.isOfficialCredentials(activity, account)) {
StatusTranslateDialogFragment.show(fragment.getFragmentManager(), status);
} else {

View File

@ -23,6 +23,8 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.AsyncTaskLoader;
@ -38,25 +40,20 @@ import org.mariotaku.twidere.R;
import org.mariotaku.twidere.app.TwidereApplication;
import org.mariotaku.twidere.model.ParcelableStatus;
import org.mariotaku.twidere.model.SingleResponse;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
import org.mariotaku.twidere.util.ImageLoaderWrapper;
import org.mariotaku.twidere.util.ImageLoadingHandler;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.view.holder.StatusListViewHolder;
import org.mariotaku.twidere.view.holder.StatusViewHolder;
import twitter4j.TranslationResult;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import static org.mariotaku.twidere.model.ParcelableLocation.isValidLocation;
import static org.mariotaku.twidere.util.UserColorNicknameUtils.getUserColor;
import static org.mariotaku.twidere.util.Utils.getCardHighlightColor;
import static org.mariotaku.twidere.util.Utils.getDefaultTextSize;
import static org.mariotaku.twidere.util.Utils.getStatusTypeIconRes;
import static org.mariotaku.twidere.util.Utils.getUserTypeIconRes;
public class StatusTranslateDialogFragment extends BaseSupportDialogFragment implements
LoaderCallbacks<SingleResponse<TranslationResult>> {
private StatusListViewHolder mHolder;
private StatusViewHolder mHolder;
private ProgressBar mProgressBar;
private TextView mMessageView;
private View mProgressContainer;
@ -89,19 +86,18 @@ public class StatusTranslateDialogFragment extends BaseSupportDialogFragment imp
}
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup parent, final Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.dialog_translate_status, parent, false);
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mProgressContainer = view.findViewById(R.id.progress_container);
mProgressBar = (ProgressBar) mProgressContainer.findViewById(android.R.id.progress);
mMessageView = (TextView) mProgressContainer.findViewById(android.R.id.message);
mStatusContainer = view.findViewById(R.id.status_container);
mHolder = new StatusListViewHolder(mStatusContainer);
mHolder.setShowAsGap(false);
mHolder.setAccountColorEnabled(true);
((View) mHolder.content).setPadding(0, 0, 0, 0);
mHolder.content.setItemBackground(null);
mHolder.content.setItemSelector(null);
return view;
mHolder = new StatusViewHolder(mStatusContainer);
}
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup parent, final Bundle savedInstanceState) {
return inflater.inflate(R.layout.dialog_translate_status, parent, false);
}
@Override
@ -129,61 +125,15 @@ public class StatusTranslateDialogFragment extends BaseSupportDialogFragment imp
private void displayTranslatedStatus(final ParcelableStatus status, final TranslationResult translated) {
if (status == null || translated == null) return;
final FragmentActivity activity = getActivity();
final TwidereApplication application = getApplication();
final ImageLoaderWrapper loader = application.getImageLoaderWrapper();
final SharedPreferences prefs = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
mHolder.setTextSize(prefs.getInt(KEY_TEXT_SIZE, getDefaultTextSize(getActivity())));
mHolder.text.setText(translated.getText());
mHolder.name.setText(status.user_name);
mHolder.screen_name.setText("@" + status.user_screen_name);
mHolder.screen_name.setVisibility(View.VISIBLE);
final String retweeted_by_name = status.retweeted_by_name;
final String retweeted_by_screen_name = status.retweeted_by_screen_name;
final boolean isMyStatus = status.account_id == status.user_id;
final boolean hasMedia = status.media != null && status.media.length > 0;
mHolder.setUserColor(getUserColor(getActivity(), status.user_id, true));
mHolder.setHighlightColor(getCardHighlightColor(getResources(), false, status.is_favorite,
status.is_retweet));
mHolder.setIsMyStatus(isMyStatus && !prefs.getBoolean(KEY_INDICATE_MY_STATUS, true));
mHolder.name.setCompoundDrawablesWithIntrinsicBounds(0, 0,
getUserTypeIconRes(status.user_is_verified, status.user_is_protected), 0);
mHolder.time.setTime(status.timestamp);
final int type_icon = getStatusTypeIconRes(status.is_favorite, isValidLocation(status.location), hasMedia,
status.is_possibly_sensitive);
mHolder.time.setCompoundDrawablesWithIntrinsicBounds(0, 0, type_icon, 0);
mHolder.reply_retweet_status
.setVisibility(status.in_reply_to_status_id != -1 || status.is_retweet ? View.VISIBLE : View.GONE);
if (status.is_retweet && !TextUtils.isEmpty(retweeted_by_name) && !TextUtils.isEmpty(retweeted_by_screen_name)) {
if (!prefs.getBoolean(KEY_NAME_FIRST, true)) {
mHolder.reply_retweet_status.setText(status.retweet_count > 1 ? getString(
R.string.retweeted_by_name_with_count, retweeted_by_screen_name, status.retweet_count - 1)
: getString(R.string.retweeted_by_name, retweeted_by_screen_name));
} else {
mHolder.reply_retweet_status.setText(status.retweet_count > 1 ? getString(
R.string.retweeted_by_name_with_count, retweeted_by_name, status.retweet_count - 1) : getString(
R.string.retweeted_by_name, retweeted_by_name));
}
mHolder.reply_retweet_status.setText(status.retweet_count > 1 ? getString(R.string.retweeted_by_name_with_count,
retweeted_by_name, status.retweet_count - 1) : getString(R.string.retweeted_by_name, retweeted_by_name));
mHolder.reply_retweet_status.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_indicator_retweet, 0, 0,
0);
} else if (status.in_reply_to_status_id > 0 && !TextUtils.isEmpty(status.in_reply_to_screen_name)) {
mHolder.reply_retweet_status.setText(getString(R.string.in_reply_to_name, status.in_reply_to_screen_name));
mHolder.reply_retweet_status.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_indicator_conversation,
0, 0, 0);
}
if (prefs.getBoolean(KEY_DISPLAY_PROFILE_IMAGE, true)) {
loader.displayProfileImage(mHolder.my_profile_image, status.user_profile_image_url);
loader.displayProfileImage(mHolder.profile_image, status.user_profile_image_url);
} else {
mHolder.profile_image.setVisibility(View.GONE);
mHolder.my_profile_image.setVisibility(View.GONE);
}
mHolder.image_preview_container.setVisibility(View.GONE);
final ImageLoadingHandler handler = new ImageLoadingHandler(R.id.media_preview_progress);
final AsyncTwitterWrapper twitter = getTwitterWrapper();
mHolder.displayStatus(activity, loader, handler, twitter, status);
mStatusContainer.findViewById(R.id.item_menu).setVisibility(View.GONE);
mStatusContainer.findViewById(R.id.action_buttons).setVisibility(View.GONE);
mStatusContainer.findViewById(R.id.reply_retweet_status).setVisibility(View.GONE);
}
public static void show(final FragmentManager fm, final ParcelableStatus status) {

View File

@ -54,6 +54,8 @@ import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.CardView;
import android.text.Html;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
@ -95,6 +97,7 @@ import org.mariotaku.twidere.model.SingleResponse;
import org.mariotaku.twidere.provider.TweetStore.Accounts;
import org.mariotaku.twidere.provider.TweetStore.CachedUsers;
import org.mariotaku.twidere.provider.TweetStore.Filters;
import org.mariotaku.twidere.text.TextAlphaSpan;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
import org.mariotaku.twidere.util.ContentValuesCreator;
import org.mariotaku.twidere.util.ImageLoaderWrapper;
@ -345,8 +348,9 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
};
public void displayUser(final ParcelableUser user) {
mUser = null;
if (user == null || user.id <= 0 || getActivity() == null) return;
mUser = user;
final FragmentActivity activity = getActivity();
if (user == null || user.id <= 0 || activity == null) return;
final Resources res = getResources();
final LoaderManager lm = getLoaderManager();
lm.destroyLoader(LOADER_ID_USER);
@ -356,10 +360,10 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
mErrorRetryContainer.setVisibility(View.GONE);
mProgressContainer.setVisibility(View.GONE);
mUser = user;
final int userColor = getUserColor(getActivity(), user.id, true);
final int userColor = getUserColor(activity, user.id, true);
mProfileImageView.setBorderColor(userColor);
mProfileNameContainer.drawEnd(getAccountColor(getActivity(), user.account_id));
final String nick = getUserNickname(getActivity(), user.id, true);
mProfileNameContainer.drawEnd(getAccountColor(activity, user.account_id));
final String nick = getUserNickname(activity, user.id, true);
mNameView
.setText(TextUtils.isEmpty(nick) ? user.name : getString(R.string.name_with_nickname, user.name, nick));
final int typeIconRes = getUserTypeIconRes(user.is_verified, user.is_protected);
@ -384,7 +388,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
mURLView.setText(isEmpty(user.url_expanded) ? user.url : user.url_expanded);
mURLView.setLinkTextColor(user.link_color);
mURLView.setMovementMethod(null);
final String createdAt = formatToLongTimeString(getActivity(), user.created_at);
final String createdAt = formatToLongTimeString(activity, user.created_at);
final float daysSinceCreated = (System.currentTimeMillis() - user.created_at) / 1000 / 60 / 60 / 24;
final int dailyTweets = Math.round(user.statuses_count / Math.max(1, daysSinceCreated));
mCreatedAtView.setText(res.getQuantityString(R.plurals.created_at_with_N_tweets_per_day, dailyTweets,
@ -404,7 +408,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
final int defWidth = res.getDisplayMetrics().widthPixels;
final int width = mBannerWidth > 0 ? mBannerWidth : defWidth;
mProfileImageLoader.displayProfileBanner(mProfileBannerView, user.profile_banner_url, width);
if (isMyAccount(getActivity(), user.id)) {
if (isMyAccount(activity, user.id)) {
final ContentResolver resolver = getContentResolver();
final ContentValues values = new ContentValues();
values.put(Accounts.NAME, user.name);
@ -419,6 +423,8 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
if (relationship == null || relationship.getTargetUserId() != user.id) {
getFriendship();
}
activity.setTitle(getDisplayName(activity, user, true));
updateTitleColor();
invalidateOptionsMenu();
}
@ -1186,6 +1192,31 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
mActionBarBackground.setFactor(factor);
mTintedStatusContent.setFactor(factor);
}
updateTitleColor();
}
private void updateTitleColor() {
final int[] location = new int[2];
mNameView.getLocationOnScreen(location);
final float nameShowingRatio = (mHeaderDrawerLayout.getPaddingTop() - location[1])
/ (float) mNameView.getHeight();
final int textAlpha = Math.round(0xFF * MathUtils.clamp(nameShowingRatio, 0, 1));
final FragmentActivity activity = getActivity();
final SpannableStringBuilder spannedTitle;
final CharSequence title = activity.getTitle();
if (title instanceof SpannableStringBuilder) {
spannedTitle = (SpannableStringBuilder) title;
} else {
spannedTitle = SpannableStringBuilder.valueOf(title);
}
final TextAlphaSpan[] spans = spannedTitle.getSpans(0, spannedTitle.length(), TextAlphaSpan.class);
if (spans.length > 0) {
spans[0].setAlpha(textAlpha);
} else {
spannedTitle.setSpan(new TextAlphaSpan(textAlpha), 0, spannedTitle.length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
activity.setTitle(spannedTitle);
}
static class RelationshipLoader extends AsyncTaskLoader<SingleResponse<Relationship>> {

View File

@ -98,13 +98,6 @@ public class ParcelableAccount implements Parcelable {
return 0;
}
@Override
public String toString() {
return "Account{screen_name=" + screen_name + ", name=" + name + ", profile_image_url=" + profile_image_url
+ ", profile_banner_url=" + profile_banner_url + ", account_id=" + account_id + ", color=" + color
+ ", is_activated=" + is_activated + ", is_dummy=" + is_dummy + "}";
}
@Override
public void writeToParcel(final Parcel out, final int flags) {
out.writeInt(is_dummy ? 1 : 0);
@ -148,7 +141,7 @@ public class ParcelableAccount implements Parcelable {
}
public static ParcelableAccount[] getAccounts(final Context context, final boolean activatedOnly,
final boolean officialKeyOnly) {
final boolean officialKeyOnly) {
final List<ParcelableAccount> list = getAccountsList(context, activatedOnly, officialKeyOnly);
return list.toArray(new ParcelableAccount[list.size()]);
}
@ -179,7 +172,7 @@ public class ParcelableAccount implements Parcelable {
}
public static List<ParcelableAccount> getAccountsList(final Context context, final boolean activatedOnly,
final boolean officialKeyOnly) {
final boolean officialKeyOnly) {
if (context == null) return Collections.emptyList();
final ArrayList<ParcelableAccount> accounts = new ArrayList<>();
final Cursor cur = ContentResolverUtils.query(context.getContentResolver(),
@ -205,7 +198,7 @@ public class ParcelableAccount implements Parcelable {
return accounts;
}
public static ParcelableAccountWithCredentials getAccountWithCredentials(final Context context, final long account_id) {
public static ParcelableCredentials getCredentials(final Context context, final long account_id) {
if (context == null) return null;
final Cursor cur = ContentResolverUtils.query(context.getContentResolver(), Accounts.CONTENT_URI,
Accounts.COLUMNS, Accounts.ACCOUNT_ID + " = " + account_id, null, null);
@ -214,7 +207,7 @@ public class ParcelableAccount implements Parcelable {
if (cur.getCount() > 0 && cur.moveToFirst()) {
final Indices indices = new Indices(cur);
cur.moveToFirst();
return new ParcelableAccountWithCredentials(cur, indices);
return new ParcelableCredentials(cur, indices);
}
} finally {
cur.close();
@ -223,7 +216,27 @@ public class ParcelableAccount implements Parcelable {
return null;
}
public static class ParcelableAccountWithCredentials extends ParcelableAccount {
@Override
public String toString() {
return "Account{screen_name=" + screen_name + ", name=" + name + ", profile_image_url=" + profile_image_url
+ ", profile_banner_url=" + profile_banner_url + ", account_id=" + account_id + ", color=" + color
+ ", is_activated=" + is_activated + ", is_dummy=" + is_dummy + "}";
}
public static class ParcelableCredentials extends ParcelableAccount {
public static final Parcelable.Creator<ParcelableCredentials> CREATOR = new Parcelable.Creator<ParcelableCredentials>() {
@Override
public ParcelableCredentials createFromParcel(final Parcel in) {
return new ParcelableCredentials(in);
}
@Override
public ParcelableCredentials[] newArray(final int size) {
return new ParcelableCredentials[size];
}
};
public final int auth_type;
public final String consumer_key, consumer_secret;
@ -232,7 +245,7 @@ public class ParcelableAccount implements Parcelable {
public final String api_url_format;
public final boolean same_oauth_signing_url, no_version_suffix;
public ParcelableAccountWithCredentials(final Cursor cursor, final Indices indices) {
public ParcelableCredentials(final Cursor cursor, final Indices indices) {
super(cursor, indices);
auth_type = cursor.getInt(indices.auth_type);
consumer_key = cursor.getString(indices.consumer_key);
@ -246,6 +259,75 @@ public class ParcelableAccount implements Parcelable {
no_version_suffix = cursor.getInt(indices.no_version_suffix) == 1;
}
public ParcelableCredentials(Parcel in) {
super(in);
auth_type = in.readInt();
consumer_key = in.readString();
consumer_secret = in.readString();
basic_auth_username = in.readString();
basic_auth_password = in.readString();
oauth_token = in.readString();
oauth_token_secret = in.readString();
api_url_format = in.readString();
same_oauth_signing_url = in.readInt() == 1;
no_version_suffix = in.readInt() == 1;
}
public static List<ParcelableCredentials> getCredentialsList(final Context context, final boolean activatedOnly) {
return getCredentialsList(context, activatedOnly, false);
}
public static List<ParcelableCredentials> getCredentialsList(final Context context, final boolean activatedOnly,
final boolean officialKeyOnly) {
if (context == null) return Collections.emptyList();
final ArrayList<ParcelableCredentials> accounts = new ArrayList<>();
final Cursor cur = ContentResolverUtils.query(context.getContentResolver(),
Accounts.CONTENT_URI, Accounts.COLUMNS,
activatedOnly ? Accounts.IS_ACTIVATED + " = 1" : null, null, Accounts.SORT_POSITION);
if (cur == null) return accounts;
final Indices indices = new Indices(cur);
cur.moveToFirst();
while (!cur.isAfterLast()) {
if (!officialKeyOnly) {
accounts.add(new ParcelableCredentials(cur, indices));
} else {
final String consumerKey = cur.getString(indices.consumer_key);
final String consumerSecret = cur.getString(indices.consumer_secret);
if (shouldForceUsingPrivateAPIs(context)
|| isOfficialConsumerKeySecret(context, consumerKey, consumerSecret)) {
accounts.add(new ParcelableCredentials(cur, indices));
}
}
cur.moveToNext();
}
cur.close();
return accounts;
}
public static boolean isOfficialCredentials(final Context context, final ParcelableCredentials account) {
if (account == null) return false;
final boolean isOAuth = account.auth_type == Accounts.AUTH_TYPE_OAUTH
|| account.auth_type == Accounts.AUTH_TYPE_XAUTH;
final String consumerKey = account.consumer_key, consumerSecret = account.consumer_secret;
return isOAuth && isOfficialConsumerKeySecret(context, consumerKey, consumerSecret);
}
@Override
public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeInt(auth_type);
out.writeString(consumer_key);
out.writeString(consumer_secret);
out.writeString(basic_auth_username);
out.writeString(basic_auth_password);
out.writeString(oauth_token);
out.writeString(oauth_token_secret);
out.writeString(api_url_format);
out.writeInt(same_oauth_signing_url ? 1 : 0);
out.writeInt(no_version_suffix ? 1 : 0);
}
@Override
public String toString() {
return "AccountWithCredentials{auth_type=" + auth_type + ", consumer_key=" + consumer_key
@ -253,14 +335,6 @@ public class ParcelableAccount implements Parcelable {
+ ", oauth_token=" + oauth_token + ", oauth_token_secret=" + oauth_token_secret
+ ", api_url_format=" + api_url_format + ", same_oauth_signing_url=" + same_oauth_signing_url + "}";
}
public static boolean isOfficialCredentials(final Context context, final ParcelableAccountWithCredentials account) {
if (account == null) return false;
final boolean isOAuth = account.auth_type == Accounts.AUTH_TYPE_OAUTH
|| account.auth_type == Accounts.AUTH_TYPE_XAUTH;
final String consumerKey = account.consumer_key, consumerSecret = account.consumer_secret;
return isOAuth && isOfficialConsumerKeySecret(context, consumerKey, consumerSecret);
}
}
public static final class Indices {

View File

@ -272,7 +272,8 @@ public class ParcelableStatus implements TwidereParcelable, Comparable<Parcelabl
first_media = media != null && media.length > 0 ? media[0].url : null;
}
public ParcelableStatus(final ParcelableStatus orig, long override_my_retweet_id) {
public ParcelableStatus(final ParcelableStatus orig, final long override_my_retweet_id,
final long override_retweet_count) {
id = orig.id;
account_id = orig.account_id;
timestamp = orig.timestamp;
@ -280,7 +281,7 @@ public class ParcelableStatus implements TwidereParcelable, Comparable<Parcelabl
retweet_id = orig.retweet_id;
retweet_timestamp = orig.retweet_timestamp;
retweeted_by_id = orig.retweeted_by_id;
retweet_count = orig.retweet_count;
retweet_count = override_retweet_count;
favorite_count = orig.favorite_count;
reply_count = orig.reply_count;
descendent_reply_count = orig.descendent_reply_count;

View File

@ -35,6 +35,7 @@ import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.TwidereLinkify;
import org.mariotaku.twidere.view.ForegroundImageView;
import org.mariotaku.twidere.view.holder.StatusListViewHolder;
import org.mariotaku.twidere.view.holder.StatusViewHolder;
import static org.mariotaku.twidere.util.HtmlEscapeHelper.toPlainText;
import static org.mariotaku.twidere.util.Utils.getDefaultTextSize;
@ -46,7 +47,7 @@ public class CardPreviewPreference extends Preference implements Constants, OnSh
private final LayoutInflater mInflater;
private final SharedPreferences mPreferences;
private final TwidereLinkify mLinkify;
private StatusListViewHolder mHolder;
private StatusViewHolder mHolder;
private boolean mCompactModeChanged;
public CardPreviewPreference(final Context context) {
@ -91,50 +92,50 @@ public class CardPreviewPreference extends Preference implements Constants, OnSh
final boolean display_image_preview = mPreferences.getBoolean(KEY_DISPLAY_IMAGE_PREVIEW, false);
final boolean display_profile_image = mPreferences.getBoolean(KEY_DISPLAY_PROFILE_IMAGE, true);
final boolean nickname_only = mPreferences.getBoolean(KEY_NICKNAME_ONLY, false);
mHolder = new StatusListViewHolder(view);
mHolder = new StatusViewHolder(view);
mLinkify.setHighlightOption(highlightOption);
mHolder.setDisplayNameFirst(nameFirst);
mHolder.setNicknameOnly(nickname_only);
mHolder.setShowAsGap(false);
mHolder.setIsMyStatus(false);
mHolder.setTextSize(mPreferences.getInt(KEY_TEXT_SIZE, getDefaultTextSize(context)));
mHolder.image_preview_container.setVisibility(display_image_preview ? View.VISIBLE : View.GONE);
mHolder.profile_image.setVisibility(display_profile_image ? View.VISIBLE : View.GONE);
mHolder.image_preview_progress.setVisibility(View.GONE);
if (mHolder.profile_image instanceof ForegroundImageView) {
((ForegroundImageView) mHolder.profile_image).setForeground(null);
}
if (mHolder.image_preview instanceof ForegroundImageView) {
((ForegroundImageView) mHolder.image_preview).setForeground(null);
}
mHolder.content.setItemSelector(null);
mHolder.profile_image.setImageResource(R.drawable.ic_launcher);
mHolder.image_preview.setImageResource(R.drawable.twidere_feature_graphic);
mHolder.name.setText(nickname_only ? TWIDERE_PREVIEW_NICKNAME : context.getString(R.string.name_with_nickname,
TWIDERE_PREVIEW_NAME, TWIDERE_PREVIEW_NICKNAME));
mHolder.screen_name.setText("@" + TWIDERE_PREVIEW_SCREEN_NAME);
if (highlightOption != VALUE_LINK_HIGHLIGHT_OPTION_CODE_NONE) {
mHolder.text.setText(Html.fromHtml(TWIDERE_PREVIEW_TEXT_HTML));
mLinkify.applyAllLinks(mHolder.text, 0, false);
mLinkify.applyUserProfileLinkNoHighlight(mHolder.name, 0, 0, TWIDERE_PREVIEW_SCREEN_NAME);
mLinkify.applyUserProfileLinkNoHighlight(mHolder.screen_name, 0, 0, TWIDERE_PREVIEW_SCREEN_NAME);
} else {
mHolder.text.setText(toPlainText(TWIDERE_PREVIEW_TEXT_HTML));
}
final String display_name = getSampleDisplayName(context, nameFirst, nickname_only);
mHolder.reply_retweet_status.setText(context.getString(R.string.retweeted_by_name, display_name));
mHolder.reply_retweet_status.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_indicator_retweet, 0, 0, 0);
mHolder.time.setTime(System.currentTimeMillis() - 360000);
mHolder.time.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_indicator_media, 0);
// mHolder.setDisplayNameFirst(nameFirst);
// mHolder.setNicknameOnly(nickname_only);
// mHolder.setShowAsGap(false);
// mHolder.setIsMyStatus(false);
// mHolder.setTextSize(mPreferences.getInt(KEY_TEXT_SIZE, getDefaultTextSize(context)));
// mHolder.image_preview_container.setVisibility(display_image_preview ? View.VISIBLE : View.GONE);
// mHolder.profile_image.setVisibility(display_profile_image ? View.VISIBLE : View.GONE);
// mHolder.image_preview_progress.setVisibility(View.GONE);
//
// if (mHolder.profile_image instanceof ForegroundImageView) {
// ((ForegroundImageView) mHolder.profile_image).setForeground(null);
// }
// if (mHolder.image_preview instanceof ForegroundImageView) {
// ((ForegroundImageView) mHolder.image_preview).setForeground(null);
// }
// mHolder.content.setItemSelector(null);
// mHolder.profile_image.setImageResource(R.drawable.ic_launcher);
// mHolder.image_preview.setImageResource(R.drawable.twidere_feature_graphic);
// mHolder.name.setText(nickname_only ? TWIDERE_PREVIEW_NICKNAME : context.getString(R.string.name_with_nickname,
// TWIDERE_PREVIEW_NAME, TWIDERE_PREVIEW_NICKNAME));
// mHolder.screen_name.setText("@" + TWIDERE_PREVIEW_SCREEN_NAME);
// if (highlightOption != VALUE_LINK_HIGHLIGHT_OPTION_CODE_NONE) {
// mHolder.text.setText(Html.fromHtml(TWIDERE_PREVIEW_TEXT_HTML));
// mLinkify.applyAllLinks(mHolder.text, 0, false);
// mLinkify.applyUserProfileLinkNoHighlight(mHolder.name, 0, 0, TWIDERE_PREVIEW_SCREEN_NAME);
// mLinkify.applyUserProfileLinkNoHighlight(mHolder.screen_name, 0, 0, TWIDERE_PREVIEW_SCREEN_NAME);
// } else {
// mHolder.text.setText(toPlainText(TWIDERE_PREVIEW_TEXT_HTML));
// }
// final String display_name = getSampleDisplayName(context, nameFirst, nickname_only);
// mHolder.reply_retweet_status.setText(context.getString(R.string.retweeted_by_name, display_name));
// mHolder.reply_retweet_status.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_indicator_retweet, 0, 0, 0);
// mHolder.time.setTime(System.currentTimeMillis() - 360000);
// mHolder.time.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_indicator_media, 0);
super.onBindView(view);
}
@Override
protected View onCreateView(final ViewGroup parent) {
if (mPreferences != null && mPreferences.getBoolean(KEY_COMPACT_CARDS, false))
return mInflater.inflate(R.layout.list_item_status_compact_deprecated, parent, false);
return mInflater.inflate(R.layout.list_item_status_deprecated, parent, false);
return mInflater.inflate(R.layout.card_item_status_compat, parent, false);
return mInflater.inflate(R.layout.card_item_status, parent, false);
}
}

View File

@ -0,0 +1,44 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.text;
import android.text.TextPaint;
import android.text.style.CharacterStyle;
/**
* Created by mariotaku on 14/12/13.
*/
public class TextAlphaSpan extends CharacterStyle {
private int alpha;
public TextAlphaSpan(int alpha) {
this.alpha = alpha;
}
public void setAlpha(int alpha) {
this.alpha = alpha;
}
@Override
public void updateDrawState(TextPaint tp) {
tp.setAlpha(alpha);
}
}

View File

@ -120,6 +120,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
private LongSparseMap<Long> mCreatingFavoriteIds = new LongSparseMap<>();
private LongSparseMap<Long> mDestroyingFavoriteIds = new LongSparseMap<>();
private LongSparseMap<Long> mCreatingRetweetIds = new LongSparseMap<>();
private LongSparseMap<Long> mDestroyingStatusIds = new LongSparseMap<>();
public AsyncTwitterWrapper(final Context context) {
mContext = context;
@ -144,10 +146,16 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
return mCreatingFavoriteIds.has(accountId, statusId);
}
public boolean isDestroyingFavorite(final long accountId, final long statusId) {
return mDestroyingFavoriteIds.has(accountId, statusId);
}
public boolean isCreatingRetweet(final long accountId, final long statusId) {
return mCreatingRetweetIds.has(accountId, statusId);
}
public boolean isDestroyingStatus(final long accountId, final long statusId) {
return mDestroyingStatusIds.has(accountId, statusId);
}
public void clearNotificationAsync(final int notificationType) {
clearNotificationAsync(notificationType, 0);
@ -1537,8 +1545,17 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
return SingleResponse.getInstance(status, exception);
}
@Override
protected void onPreExecute() {
super.onPreExecute();
mDestroyingStatusIds.put(account_id, status_id);
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
bus.post(new StatusListChangedEvent());
}
@Override
protected void onPostExecute(final SingleResponse<ParcelableStatus> result) {
mDestroyingStatusIds.remove(account_id, status_id);
if (result.hasData()) {
final ParcelableStatus status = result.getData();
if (status.retweet_id > 0) {
@ -2103,8 +2120,17 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
}
}
@Override
protected void onPreExecute() {
super.onPreExecute();
mCreatingRetweetIds.put(account_id, status_id);
final Bus bus = TwidereApplication.getInstance(mContext).getMessageBus();
bus.post(new StatusListChangedEvent());
}
@Override
protected void onPostExecute(final SingleResponse<ParcelableStatus> result) {
mCreatingRetweetIds.remove(account_id, status_id);
if (result.hasData()) {
final ContentValues values = new ContentValues();
final ParcelableStatus status = result.getData();
@ -2122,7 +2148,6 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
} else {
mMessagesManager.showErrorMessage(R.string.action_retweeting, result.getException(), true);
}
super.onPostExecute(result);
}

View File

@ -319,23 +319,6 @@ public class ThemeUtils implements Constants {
return 0xCCFFFFFF;
}
public static Drawable getCardItemBackground(final Context context) {
final TypedArray a = context.obtainStyledAttributes(new int[]{R.attr.cardItemBackground});
final Drawable d = a.getDrawable(0);
a.recycle();
return d;
}
public static Drawable getCardItemMenuOverflowButtonDrawable(final Context context) {
final Resources res = getResources(context);
final TypedArray a = context.obtainStyledAttributes(new int[]{R.attr.cardOverflowIcon});
final Drawable d = a.getDrawable(0);
a.recycle();
if (d == null) return res.getDrawable(R.drawable.ic_menu_moreoverflow_card_light);
return d;
}
public static int getColorBackgroundCacheHint(final Context context) {
final TypedArray a = context.obtainStyledAttributes(new int[]{android.R.attr.colorBackgroundCacheHint});
final int color = a.getColor(0, Color.TRANSPARENT);
@ -404,16 +387,6 @@ public class ThemeUtils implements Constants {
return d;
}
public static Drawable getListMenuOverflowButtonDrawable(final Context context) {
final Resources res = getResources(context);
final TypedArray a = context.obtainStyledAttributes(new int[]{R.attr.listMenuOverflowButton});
final Drawable d = a.getDrawable(0);
a.recycle();
if (d == null)
return res.getDrawable(R.drawable.ic_list_menu_moreoverflow_normal_holo_light);
return d;
}
public static int getMenuIconColor(final Context context) {
return getMenuIconColor(getThemeResource(context));
}

View File

@ -158,7 +158,7 @@ import org.mariotaku.twidere.graphic.PaddingDrawable;
import org.mariotaku.twidere.menu.StatusShareProvider;
import org.mariotaku.twidere.model.AccountPreferences;
import org.mariotaku.twidere.model.ParcelableAccount;
import org.mariotaku.twidere.model.ParcelableAccount.ParcelableAccountWithCredentials;
import org.mariotaku.twidere.model.ParcelableAccount.ParcelableCredentials;
import org.mariotaku.twidere.model.ParcelableDirectMessage;
import org.mariotaku.twidere.model.ParcelableLocation;
import org.mariotaku.twidere.model.ParcelableStatus;
@ -649,7 +649,6 @@ public final class Utils implements Constants, TwitterConstants {
if (context == null) return;
configBaseAdapter(context, adapter);
final SharedPreferences pref = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
adapter.setAnimationEnabled(pref.getBoolean(KEY_CARD_ANIMATION, true));
adapter.notifyDataSetChanged();
}
@ -2271,7 +2270,7 @@ public final class Utils implements Constants, TwitterConstants {
return date.getTime();
}
public static Authorization getTwitterAuthorization(final Context context, final ParcelableAccountWithCredentials account) {
public static Authorization getTwitterAuthorization(final Context context, final ParcelableCredentials account) {
if (context == null || account == null) return null;
switch (account.auth_type) {
case Accounts.AUTH_TYPE_OAUTH:
@ -3499,14 +3498,14 @@ public final class Utils implements Constants, TwitterConstants {
public static void setMenuForStatus(final Context context, final Menu menu,
final ParcelableStatus status) {
final ParcelableAccountWithCredentials account
= ParcelableAccount.getAccountWithCredentials(context, status.account_id);
final ParcelableCredentials account
= ParcelableAccount.getCredentials(context, status.account_id);
setMenuForStatus(context, menu, status, account);
}
public static void setMenuForStatus(final Context context, final Menu menu,
final ParcelableStatus status,
final ParcelableAccountWithCredentials account) {
final ParcelableCredentials account) {
if (context == null || menu == null || status == null) return;
final Resources resources = context.getResources();
final int retweetHighlight = resources.getColor(R.color.highlight_retweet);
@ -3534,7 +3533,7 @@ public final class Utils implements Constants, TwitterConstants {
}
final MenuItem translate = menu.findItem(MENU_TRANSLATE);
if (translate != null) {
final boolean isOfficialKey = ParcelableAccountWithCredentials.isOfficialCredentials(context, account);
final boolean isOfficialKey = ParcelableCredentials.isOfficialCredentials(context, account);
setMenuItemAvailability(menu, MENU_TRANSLATE, isOfficialKey);
}
menu.removeGroup(MENU_GROUP_STATUS_EXTENSION);

View File

@ -36,7 +36,7 @@ import com.nostra13.universalimageloader.core.download.BaseImageDownloader;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.model.ParcelableAccount;
import org.mariotaku.twidere.model.ParcelableAccount.ParcelableAccountWithCredentials;
import org.mariotaku.twidere.model.ParcelableAccount.ParcelableCredentials;
import org.mariotaku.twidere.model.ParcelableMedia;
import org.mariotaku.twidere.util.MediaPreviewUtils;
import org.mariotaku.twidere.util.Utils;
@ -125,10 +125,10 @@ public class TwidereImageDownloader extends BaseImageDownloader implements Const
throws IOException, TwitterException {
final Uri uri = Uri.parse(uriString);
final Authorization auth;
final ParcelableAccountWithCredentials account;
final ParcelableCredentials account;
if (isTwitterAuthRequired(uri) && extras instanceof AccountExtra) {
final AccountExtra accountExtra = (AccountExtra) extras;
account = ParcelableAccount.getAccountWithCredentials(mContext, accountExtra.account_id);
account = ParcelableAccount.getCredentials(mContext, accountExtra.account_id);
auth = getTwitterAuthorization(mContext, accountExtra.account_id);
} else {
account = null;

View File

@ -1,140 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.view.iface.ICardItemView;
public class CardItemFrameLayout extends ColorLabelFrameLayout implements ICardItemView {
private final DrawingHelper mDrawingHelper;
public CardItemFrameLayout(final Context context) {
this(context, null);
}
public CardItemFrameLayout(final Context context, final AttributeSet attrs) {
this(context, attrs, R.attr.cardItemViewStyle);
}
public CardItemFrameLayout(final Context context, final AttributeSet attrs, final int defStyleAttr) {
super(context, attrs, defStyleAttr);
mDrawingHelper = new DrawingHelper(this, context, attrs, defStyleAttr);
}
@Override
public boolean dispatchTouchEvent(final MotionEvent ev) {
if (mDrawingHelper.isGap()) return false;
if (mDrawingHelper.isOverflowIconClicked(ev)) {
mDrawingHelper.handleOverflowTouchEvent(ev);
return true;
}
return super.dispatchTouchEvent(ev);
}
@Override
public View getFakeOverflowButton() {
return mDrawingHelper.getFakeOverflowButton();
}
@Override
public boolean isGap() {
return mDrawingHelper.isGap();
}
@Override
public void setActivatedIndicator(final Drawable activatedIndicator) {
mDrawingHelper.setActivatedIndicator(activatedIndicator);
}
@Override
public void setIsGap(final boolean isGap) {
mDrawingHelper.setIsGap(isGap);
}
@Override
public void setItemBackground(final Drawable itemBackground) {
mDrawingHelper.setItemBackground(itemBackground);
}
@Override
public void setItemSelector(final Drawable itemSelector) {
mDrawingHelper.setItemSelector(itemSelector);
}
@Override
public void setOnOverflowIconClickListener(final OnOverflowIconClickListener listener) {
mDrawingHelper.setOnOverflowIconClickListener(listener);
}
@Override
public void setOverflowIcon(final Drawable overflowIcon) {
mDrawingHelper.setOverflowIcon(overflowIcon);
}
@Override
protected void dispatchDraw(final Canvas canvas) {
if (mDrawingHelper.isGap()) {
mDrawingHelper.drawGap(canvas);
} else {
mDrawingHelper.drawBackground(canvas);
super.dispatchDraw(canvas);
mDrawingHelper.drawOverflowIcon(canvas);
}
mDrawingHelper.drawSelector(canvas);
}
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
mDrawingHelper.dispatchDrawableStateChanged();
}
@Override
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
final int measuredWidth = MeasureSpec.getSize(widthMeasureSpec);
if (mDrawingHelper.isGap()) {
setMeasuredDimension(measuredWidth, mDrawingHelper.getCardGapHeight());
} else {
final int measuredHeight = MeasureSpec.getSize(widthMeasureSpec);
setMeasuredDimension(measuredWidth, measuredHeight);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
@Override
protected void onSizeChanged(final int w, final int h, final int oldw, final int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mDrawingHelper.dispatchOnSizeChanged(w, h, oldw, oldh);
}
@Override
protected boolean verifyDrawable(final Drawable who) {
return super.verifyDrawable(who) || mDrawingHelper.verifyDrawable(who);
}
}

View File

@ -1,140 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.view.iface.ICardItemView;
public class CardItemLinearLayout extends ColorLabelLinearLayout implements ICardItemView {
private final DrawingHelper mDrawingHelper;
public CardItemLinearLayout(final Context context) {
this(context, null);
}
public CardItemLinearLayout(final Context context, final AttributeSet attrs) {
this(context, attrs, R.attr.cardItemViewStyle);
}
public CardItemLinearLayout(final Context context, final AttributeSet attrs, final int defStyleAttr) {
super(context, attrs, defStyleAttr);
mDrawingHelper = new DrawingHelper(this, context, attrs, defStyleAttr);
}
@Override
public boolean dispatchTouchEvent(final MotionEvent ev) {
if (mDrawingHelper.isGap()) return false;
if (mDrawingHelper.isOverflowIconClicked(ev)) {
mDrawingHelper.handleOverflowTouchEvent(ev);
return true;
}
return super.dispatchTouchEvent(ev);
}
@Override
public View getFakeOverflowButton() {
return mDrawingHelper.getFakeOverflowButton();
}
@Override
public boolean isGap() {
return mDrawingHelper.isGap();
}
@Override
public void setActivatedIndicator(final Drawable activatedIndicator) {
mDrawingHelper.setActivatedIndicator(activatedIndicator);
}
@Override
public void setIsGap(final boolean isGap) {
mDrawingHelper.setIsGap(isGap);
}
@Override
public void setItemBackground(final Drawable itemBackground) {
mDrawingHelper.setItemBackground(itemBackground);
}
@Override
public void setItemSelector(final Drawable itemSelector) {
mDrawingHelper.setItemSelector(itemSelector);
}
@Override
public void setOnOverflowIconClickListener(final OnOverflowIconClickListener listener) {
mDrawingHelper.setOnOverflowIconClickListener(listener);
}
@Override
public void setOverflowIcon(final Drawable overflowIcon) {
mDrawingHelper.setOverflowIcon(overflowIcon);
}
@Override
protected void dispatchDraw(final Canvas canvas) {
if (mDrawingHelper.isGap()) {
mDrawingHelper.drawGap(canvas);
} else {
mDrawingHelper.drawBackground(canvas);
super.dispatchDraw(canvas);
mDrawingHelper.drawOverflowIcon(canvas);
}
mDrawingHelper.drawSelector(canvas);
}
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
mDrawingHelper.dispatchDrawableStateChanged();
}
@Override
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
final int measuredWidth = MeasureSpec.getSize(widthMeasureSpec);
if (mDrawingHelper.isGap()) {
setMeasuredDimension(measuredWidth, mDrawingHelper.getCardGapHeight());
} else {
final int measuredHeight = MeasureSpec.getSize(widthMeasureSpec);
setMeasuredDimension(measuredWidth, measuredHeight);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
@Override
protected void onSizeChanged(final int w, final int h, final int oldw, final int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mDrawingHelper.dispatchOnSizeChanged(w, h, oldw, oldh);
}
@Override
protected boolean verifyDrawable(final Drawable who) {
return super.verifyDrawable(who) || mDrawingHelper.verifyDrawable(who);
}
}

View File

@ -1,139 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.view.iface.ICardItemView;
public class CardItemRelativeLayout extends ColorLabelRelativeLayout implements ICardItemView {
private final DrawingHelper mDrawingHelper;
public CardItemRelativeLayout(final Context context) {
this(context, null);
}
public CardItemRelativeLayout(final Context context, final AttributeSet attrs) {
this(context, attrs, R.attr.cardItemViewStyle);
}
public CardItemRelativeLayout(final Context context, final AttributeSet attrs, final int defStyleAttr) {
super(context, attrs, defStyleAttr);
mDrawingHelper = new DrawingHelper(this, context, attrs, defStyleAttr);
}
@Override
public boolean dispatchTouchEvent(final MotionEvent ev) {
if (mDrawingHelper.isGap()) return false;
if (mDrawingHelper.isOverflowIconClicked(ev)) {
mDrawingHelper.handleOverflowTouchEvent(ev);
return true;
}
return super.dispatchTouchEvent(ev);
}
@Override
public View getFakeOverflowButton() {
return mDrawingHelper.getFakeOverflowButton();
}
@Override
public boolean isGap() {
return mDrawingHelper.isGap();
}
@Override
public void setActivatedIndicator(final Drawable activatedIndicator) {
mDrawingHelper.setActivatedIndicator(activatedIndicator);
}
@Override
public void setIsGap(final boolean isGap) {
mDrawingHelper.setIsGap(isGap);
}
@Override
public void setItemBackground(final Drawable itemBackground) {
mDrawingHelper.setItemBackground(itemBackground);
}
@Override
public void setItemSelector(final Drawable itemSelector) {
mDrawingHelper.setItemSelector(itemSelector);
}
@Override
public void setOnOverflowIconClickListener(final OnOverflowIconClickListener listener) {
mDrawingHelper.setOnOverflowIconClickListener(listener);
}
@Override
public void setOverflowIcon(final Drawable overflowIcon) {
mDrawingHelper.setOverflowIcon(overflowIcon);
}
@Override
protected void dispatchDraw(final Canvas canvas) {
if (mDrawingHelper.isGap()) {
mDrawingHelper.drawGap(canvas);
} else {
mDrawingHelper.drawBackground(canvas);
super.dispatchDraw(canvas);
mDrawingHelper.drawOverflowIcon(canvas);
}
mDrawingHelper.drawSelector(canvas);
}
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
mDrawingHelper.dispatchDrawableStateChanged();
}
@Override
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
final int measuredWidth = MeasureSpec.getSize(widthMeasureSpec);
if (mDrawingHelper.isGap()) {
setMeasuredDimension(measuredWidth, mDrawingHelper.getCardGapHeight());
} else {
final int measuredHeight = MeasureSpec.getSize(widthMeasureSpec);
setMeasuredDimension(measuredWidth, measuredHeight);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
@Override
protected void onSizeChanged(final int w, final int h, final int oldw, final int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mDrawingHelper.dispatchOnSizeChanged(w, h, oldw, oldh);
}
@Override
protected boolean verifyDrawable(final Drawable who) {
return super.verifyDrawable(who) || mDrawingHelper.verifyDrawable(who);
}
}

View File

@ -1,90 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.PorterDuff.Mode;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.ImageView;
import org.mariotaku.twidere.util.ThemeUtils;
public class ListMenuOverflowButton extends ImageView {
private final int mHighlightColor;
private final Rect mRect;
private boolean mIsDown;
public ListMenuOverflowButton(final Context context) {
this(context, null);
}
public ListMenuOverflowButton(final Context context, final AttributeSet attrs) {
this(context, attrs, 0);
}
public ListMenuOverflowButton(final Context context, final AttributeSet attrs, final int defStyle) {
super(context, attrs, defStyle);
setScaleType(ScaleType.CENTER_INSIDE);
mHighlightColor = isInEditMode() ? 0 : ThemeUtils.getUserAccentColor(context);
mRect = new Rect();
final TypedArray a = context.obtainStyledAttributes(attrs, new int[] { android.R.attr.src });
if (!a.hasValue(0)) {
setImageDrawable(ThemeUtils.getListMenuOverflowButtonDrawable(context));
}
a.recycle();
}
@Override
public boolean onTouchEvent(final MotionEvent e) {
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
mRect.set(getLeft(), getTop(), getRight(), getBottom());
mIsDown = true;
updateColorFilter();
break;
case MotionEvent.ACTION_MOVE:
if (mRect.contains(getLeft() + (int) e.getX(), getTop() + (int) e.getY())) {
break;
}
if (mIsDown) {
mIsDown = false;
updateColorFilter();
}
break;
default:
mIsDown = false;
updateColorFilter();
break;
}
return super.onTouchEvent(e);
}
private void updateColorFilter() {
if (mIsDown && isClickable() && isEnabled()) {
setColorFilter(mHighlightColor, Mode.SRC_ATOP);
} else {
clearColorFilter();
}
}
}

View File

@ -23,6 +23,7 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.adapter.decorator.DividerItemDecoration;
import org.mariotaku.twidere.view.iface.PagerIndicator;
import java.lang.annotation.Retention;
@ -39,6 +40,8 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator {
private final int mStripHeight;
private final TabPagerIndicatorAdapter mIndicatorAdapter;
private final TabLayoutManager mLayoutManager;
private final DividerItemDecoration mItemDecoration;
private ViewPager mViewPager;
private PagerAdapter mPagerProvider;
@ -51,11 +54,12 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator {
super(context, attrs, defStyle);
final Resources res = getResources();
mIndicatorAdapter = new TabPagerIndicatorAdapter(this);
mStripHeight = getResources().getDimensionPixelSize(R.dimen.element_spacing_small);
mItemDecoration = new DividerItemDecoration(context, HORIZONTAL);
mStripHeight = res.getDimensionPixelSize(R.dimen.element_spacing_small);
ViewCompat.setOverScrollMode(this, ViewCompat.OVER_SCROLL_NEVER);
setHorizontalScrollBarEnabled(false);
setVerticalScrollBarEnabled(false);
setLayoutManager(new TabLayoutManager(this));
setLayoutManager(mLayoutManager = new TabLayoutManager(this));
setItemContext(context);
setAdapter(mIndicatorAdapter);
setTabDisplayOption(ICON);
@ -66,9 +70,22 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator {
setStripColor(a.getColor(R.styleable.TabPagerIndicator_tabStripColor, 0));
setIconColor(a.getColor(R.styleable.TabPagerIndicator_tabIconColor, 0));
setTabDisplayOption(a.getInt(R.styleable.TabPagerIndicator_tabDisplayOption, ICON));
setTabShowDivider(a.getBoolean(R.styleable.TabPagerIndicator_tabShowDivider, false));
final int dividerVerticalPadding = a.getDimensionPixelSize(R.styleable.TabPagerIndicator_tabDividerVerticalPadding, 0);
final int dividerHorizontalPadding = a.getDimensionPixelSize(R.styleable.TabPagerIndicator_tabDividerHorizontalPadding, 0);
mItemDecoration.setPadding(dividerHorizontalPadding, dividerVerticalPadding,
dividerHorizontalPadding, dividerVerticalPadding);
a.recycle();
}
private void setTabShowDivider(boolean showDivider) {
if (showDivider) {
addItemDecoration(mItemDecoration);
} else {
removeItemDecoration(mItemDecoration);
}
}
public TabPagerIndicator(Context context, AttributeSet attrs) {
this(context, attrs, 0);
@ -109,6 +126,7 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator {
public void onPageSelected(int position) {
mIndicatorAdapter.notifyDataSetChanged();
if (mPageChangeListener == null) return;
smoothScrollToPosition(position);
mPageChangeListener.onPageSelected(position);
}
@ -373,7 +391,7 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator {
}
}
public static class TabLayoutManager extends LinearLayoutManager {
private static class TabLayoutManager extends LinearLayoutManager {
private final TabPagerIndicator mIndicator;

View File

@ -22,18 +22,15 @@ package org.mariotaku.twidere.view.holder;
import android.view.View;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.animation.CardItemAnimation;
import org.mariotaku.twidere.view.iface.ICardItemView;
import org.mariotaku.twidere.view.iface.IColorLabelView;
public class CardViewHolder extends ViewHolder {
public class CardViewHolder extends ListViewHolder {
public final CardItemAnimation item_animation;
public final ICardItemView content;
public final IColorLabelView content;
public CardViewHolder(final View view) {
super(view);
content = (ICardItemView) view.findViewById(R.id.content);
item_animation = new CardItemAnimation();
}
public CardViewHolder(final View view) {
super(view);
content = (IColorLabelView) view.findViewById(R.id.content);
}
}

View File

@ -31,7 +31,7 @@ import android.widget.TextView;
import org.mariotaku.messagebubbleview.library.MessageBubbleView;
import org.mariotaku.twidere.R;
public class DirectMessageConversationViewHolder extends CardViewHolder {
public class DirectMessageConversationViewHolder extends ListViewHolder {
public final TextView text, time;

View File

@ -20,7 +20,6 @@
package org.mariotaku.twidere.view.holder;
import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
@ -29,7 +28,7 @@ import org.mariotaku.twidere.R;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.view.ShortTimeView;
public class DirectMessageEntryViewHolder extends ViewHolder {
public class DirectMessageEntryViewHolder extends ListViewHolder {
public final ImageView profile_image;
public final TextView name, text;

View File

@ -26,7 +26,7 @@ import android.widget.TextView;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.view.iface.IColorLabelView;
public class DraftViewHolder extends ViewHolder {
public class DraftViewHolder extends ListViewHolder {
public final IColorLabelView content;
public final TextView text;

View File

@ -24,11 +24,11 @@ import android.view.View;
import org.mariotaku.twidere.Constants;
public class ViewHolder implements Constants {
public class ListViewHolder implements Constants {
public View view;
public ViewHolder(final View view) {
public ListViewHolder(final View view) {
if (view == null) throw new NullPointerException();
this.view = view;
}

View File

@ -45,7 +45,6 @@ public class StatusListViewHolder extends CardViewHolder {
public final TextView name, screen_name, reply_retweet_status;
public final ShortTimeView time;
public final TextView text;
public final TextView image_preview_count;
private final float density;
private final boolean is_rtl;
@ -70,8 +69,7 @@ public class StatusListViewHolder extends CardViewHolder {
text = (TextView) findViewById(R.id.text);
time = (ShortTimeView) findViewById(R.id.time);
reply_retweet_status = (TextView) findViewById(R.id.reply_retweet_status);
image_preview_count = (TextView) findViewById(R.id.image_preview_count);
show_as_gap = content.isGap();
show_as_gap = false;
is_rtl = Utils.isRTL(context);
density = context.getResources().getDisplayMetrics().density;
}
@ -143,7 +141,6 @@ public class StatusListViewHolder extends CardViewHolder {
public void setShowAsGap(final boolean show_gap) {
show_as_gap = show_gap;
if (content != null) {
content.setIsGap(show_gap);
}
// if (item_menu != null) {
// item_menu.setVisibility(show_gap ? View.GONE : View.VISIBLE);
@ -164,7 +161,6 @@ public class StatusListViewHolder extends CardViewHolder {
screen_name.setTextSize(text_size * 0.75f);
time.setTextSize(text_size * 0.65f);
reply_retweet_status.setTextSize(text_size * 0.65f);
image_preview_count.setTextSize(text_size * 1.25f);
return true;
}

View File

@ -2,6 +2,8 @@ package org.mariotaku.twidere.view.holder;
import android.content.Context;
import android.database.Cursor;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.view.View;
@ -24,6 +26,8 @@ import org.mariotaku.twidere.view.ShortTimeView;
import java.util.Locale;
import twitter4j.TranslationResult;
import static org.mariotaku.twidere.util.Utils.getUserTypeIconRes;
/**
@ -91,18 +95,17 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements OnClick
public void displayStatus(final Context context, final ImageLoaderWrapper loader,
final ImageLoadingHandler handler, final AsyncTwitterWrapper twitter,
final ParcelableStatus status) {
displayStatus(context, loader, handler, twitter, status, null);
}
public void displayStatus(final Context context, final ImageLoaderWrapper loader,
final ImageLoadingHandler handler, final AsyncTwitterWrapper twitter,
@NonNull final ParcelableStatus status,
@Nullable final TranslationResult translation) {
final ParcelableMedia[] media = status.media;
if (status.retweet_id > 0) {
if (status.retweet_count == 2) {
replyRetweetView.setText(context.getString(R.string.name_and_another_retweeted,
status.retweeted_by_name));
} else if (status.retweet_count > 2) {
replyRetweetView.setText(context.getString(R.string.name_and_count_retweeted,
status.retweeted_by_name, status.retweet_count - 1));
} else {
replyRetweetView.setText(context.getString(R.string.name_retweeted, status.retweeted_by_name));
}
replyRetweetView.setText(context.getString(R.string.name_retweeted, status.retweeted_by_name));
replyRetweetView.setVisibility(View.VISIBLE);
retweetProfileImageView.setVisibility(View.GONE);
} else if (status.in_reply_to_status_id > 0 && status.in_reply_to_user_id > 0) {
@ -136,40 +139,54 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements OnClick
if (media != null && media.length > 0) {
final ParcelableMedia firstMedia = media[0];
textView.setText(status.text_unescaped);
loader.displayPreviewImageWithCredentials(mediaPreviewView, firstMedia.media_url,
status.account_id, handler);
mediaPreviewContainer.setVisibility(View.VISIBLE);
} else {
loader.cancelDisplayTask(mediaPreviewView);
textView.setText(status.text_unescaped);
mediaPreviewContainer.setVisibility(View.GONE);
}
if (translation != null) {
textView.setText(translation.getText());
} else {
textView.setText(status.text_unescaped);
}
if (status.reply_count > 0) {
replyCountView.setText(Utils.getLocalizedNumber(Locale.getDefault(), status.reply_count));
} else {
replyCountView.setText(null);
}
if (status.retweet_count > 0) {
retweetCountView.setText(Utils.getLocalizedNumber(Locale.getDefault(), status.retweet_count));
final long retweet_count;
if (twitter.isDestroyingStatus(status.account_id, status.my_retweet_id)) {
retweetCountView.setActivated(false);
retweet_count = Math.max(0, status.favorite_count - 1);
} else {
final boolean creatingRetweet = twitter.isCreatingRetweet(status.account_id, status.id);
retweetCountView.setActivated(creatingRetweet || Utils.isMyRetweet(status));
retweet_count = status.retweet_count + (creatingRetweet ? 1 : 0);
}
if (retweet_count > 0) {
retweetCountView.setText(Utils.getLocalizedNumber(Locale.getDefault(), retweet_count));
} else {
retweetCountView.setText(null);
}
if (status.favorite_count > 0) {
favoriteCountView.setText(Utils.getLocalizedNumber(Locale.getDefault(), status.favorite_count));
} else {
favoriteCountView.setText(null);
}
retweetCountView.setEnabled(!status.user_is_protected);
retweetCountView.setActivated(Utils.isMyRetweet(status));
final long favorite_count;
if (twitter.isDestroyingFavorite(status.account_id, status.id)) {
favoriteCountView.setActivated(false);
favorite_count = Math.max(0, status.favorite_count - 1);
} else {
favoriteCountView.setActivated(twitter.isCreatingFavorite(status.account_id, status.id)
|| status.is_favorite);
final boolean creatingFavorite = twitter.isCreatingFavorite(status.account_id, status.id);
favoriteCountView.setActivated(creatingFavorite || status.is_favorite);
favorite_count = status.favorite_count + (creatingFavorite ? 1 : 0);
}
if (favorite_count > 0) {
favoriteCountView.setText(Utils.getLocalizedNumber(Locale.getDefault(), favorite_count));
} else {
favoriteCountView.setText(null);
}
}
@ -179,9 +196,9 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements OnClick
final AsyncTwitterWrapper twitter = adapter.getTwitterWrapper();
final Context context = adapter.getContext();
final int reply_count = cursor.getInt(indices.reply_count);
final int retweet_count = cursor.getInt(indices.retweet_count);
final int favorite_count = cursor.getInt(indices.favorite_count);
final long reply_count = cursor.getLong(indices.reply_count);
final long retweet_count;
final long favorite_count;
final long account_id = cursor.getLong(indices.account_id);
final long timestamp = cursor.getLong(indices.status_timestamp);
@ -204,15 +221,7 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements OnClick
final ParcelableMedia[] media = ParcelableMedia.fromJSONString(cursor.getString(indices.media));
if (retweet_id > 0) {
if (retweet_count == 2) {
replyRetweetView.setText(context.getString(R.string.name_and_another_retweeted,
retweeted_by_name));
} else if (retweet_count > 2) {
replyRetweetView.setText(context.getString(R.string.name_and_count_retweeted,
retweeted_by_name, retweet_count - 1));
} else {
replyRetweetView.setText(context.getString(R.string.name_retweeted, retweeted_by_name));
}
replyRetweetView.setText(context.getString(R.string.name_retweeted, retweeted_by_name));
replyRetweetView.setVisibility(View.VISIBLE);
retweetProfileImageView.setVisibility(View.GONE);
} else if (in_reply_to_status_id > 0 && in_reply_to_user_id > 0) {
@ -264,26 +273,37 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements OnClick
} else {
replyCountView.setText(null);
}
if (twitter.isDestroyingStatus(account_id, my_retweet_id)) {
retweetCountView.setActivated(false);
retweet_count = Math.max(0, cursor.getLong(indices.retweet_count) - 1);
} else {
final boolean creatingRetweet = twitter.isCreatingRetweet(account_id, status_id);
retweetCountView.setActivated(creatingRetweet || Utils.isMyRetweet(account_id,
retweeted_by_id, my_retweet_id));
retweet_count = cursor.getLong(indices.retweet_count) + (creatingRetweet ? 1 : 0);
}
if (retweet_count > 0) {
retweetCountView.setText(Utils.getLocalizedNumber(Locale.getDefault(), retweet_count));
} else {
retweetCountView.setText(null);
}
retweetCountView.setEnabled(!user_is_protected);
favoriteCountView.setActivated(cursor.getInt(indices.is_favorite) == 1);
if (twitter.isDestroyingFavorite(account_id, status_id)) {
favoriteCountView.setActivated(false);
favorite_count = Math.max(0, cursor.getLong(indices.favorite_count) - 1);
} else {
final boolean creatingFavorite = twitter.isCreatingFavorite(account_id, status_id);
favoriteCountView.setActivated(creatingFavorite || cursor.getInt(indices.is_favorite) == 1);
favorite_count = cursor.getLong(indices.favorite_count) + (creatingFavorite ? 1 : 0);
}
if (favorite_count > 0) {
favoriteCountView.setText(Utils.getLocalizedNumber(Locale.getDefault(), favorite_count));
} else {
favoriteCountView.setText(null);
}
retweetCountView.setEnabled(!user_is_protected);
retweetCountView.setActivated(Utils.isMyRetweet(account_id, retweeted_by_id, my_retweet_id));
favoriteCountView.setActivated(cursor.getInt(indices.is_favorite) == 1);
if (twitter.isDestroyingFavorite(account_id, status_id)) {
favoriteCountView.setActivated(false);
} else {
favoriteCountView.setActivated(twitter.isCreatingFavorite(account_id, status_id)
|| cursor.getInt(indices.is_favorite) == 1);
}
}
public CardView getCardView() {

View File

@ -23,7 +23,7 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
public class TwoLineWithIconViewHolder extends ViewHolder {
public class TwoLineWithIconViewHolder extends ListViewHolder {
public final ImageView icon;
public final TextView text1, text2;

View File

@ -19,65 +19,38 @@
package org.mariotaku.twidere.view.holder;
import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.view.iface.IColorLabelView;
public class UserViewHolder extends CardViewHolder {
public class UserListListViewHolder extends ListViewHolder {
public final IColorLabelView content;
public final ImageView profile_image;
public final TextView name, screen_name, description, location, url, statuses_count, followers_count,
friends_count;
private boolean account_color_enabled;
public final TextView name, description, created_by, members_count, subscribers_count;
private float text_size;
public int position;
public UserViewHolder(final View view) {
public UserListListViewHolder(final View view) {
super(view);
content = (IColorLabelView) view.findViewById(R.id.content);
profile_image = (ImageView) findViewById(R.id.profile_image);
name = (TextView) findViewById(R.id.name);
screen_name = (TextView) findViewById(R.id.screen_name);
description = (TextView) findViewById(R.id.description);
location = (TextView) findViewById(R.id.location);
url = (TextView) findViewById(R.id.url);
statuses_count = (TextView) findViewById(R.id.statuses_count);
followers_count = (TextView) findViewById(R.id.followers_count);
friends_count = (TextView) findViewById(R.id.friends_count);
}
public void setAccountColor(final int color) {
content.drawEnd(account_color_enabled ? color : Color.TRANSPARENT);
}
public void setAccountColorEnabled(final boolean enabled) {
account_color_enabled = enabled;
if (!account_color_enabled) {
content.drawEnd(Color.TRANSPARENT);
}
}
public void setHighlightColor(final int color) {
content.drawBackground(color);
created_by = (TextView) findViewById(R.id.created_by);
members_count = (TextView) findViewById(R.id.members_count);
subscribers_count = (TextView) findViewById(R.id.subscribers_count);
}
public void setTextSize(final float text_size) {
if (this.text_size == text_size) return;
this.text_size = text_size;
description.setTextSize(text_size);
name.setTextSize(text_size);
screen_name.setTextSize(text_size * 0.75f);
location.setTextSize(text_size);
url.setTextSize(text_size);
statuses_count.setTextSize(text_size);
followers_count.setTextSize(text_size);
friends_count.setTextSize(text_size);
}
public void setUserColor(final int color) {
content.drawStart(color);
name.setTextSize(text_size * 1.05f);
created_by.setTextSize(text_size * 0.65f);
}
}

View File

@ -19,35 +19,69 @@
package org.mariotaku.twidere.view.holder;
import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.view.iface.IColorLabelView;
public class UserListViewHolder extends CardViewHolder {
public class UserListViewHolder extends ListViewHolder {
public final ImageView profile_image;
public final TextView name, description, created_by, members_count, subscribers_count;
public final IColorLabelView content;
public final ImageView profile_image, profile_type;
public final TextView name, screen_name, description, location, url, statuses_count, followers_count,
friends_count;
private boolean account_color_enabled;
private float text_size;
public int position;
public UserListViewHolder(final View view) {
super(view);
content = (IColorLabelView) view.findViewById(R.id.content);
profile_image = (ImageView) findViewById(R.id.profile_image);
profile_type = (ImageView) findViewById(R.id.profile_type);
name = (TextView) findViewById(R.id.name);
screen_name = (TextView) findViewById(R.id.screen_name);
description = (TextView) findViewById(R.id.description);
created_by = (TextView) findViewById(R.id.created_by);
members_count = (TextView) findViewById(R.id.members_count);
subscribers_count = (TextView) findViewById(R.id.subscribers_count);
location = (TextView) findViewById(R.id.location);
url = (TextView) findViewById(R.id.url);
statuses_count = (TextView) findViewById(R.id.statuses_count);
followers_count = (TextView) findViewById(R.id.followers_count);
friends_count = (TextView) findViewById(R.id.friends_count);
}
public void setAccountColor(final int color) {
content.drawEnd(account_color_enabled ? color : Color.TRANSPARENT);
}
public void setAccountColorEnabled(final boolean enabled) {
account_color_enabled = enabled;
if (!account_color_enabled) {
content.drawEnd(Color.TRANSPARENT);
}
}
public void setHighlightColor(final int color) {
content.drawBackground(color);
}
public void setTextSize(final float text_size) {
if (this.text_size == text_size) return;
this.text_size = text_size;
description.setTextSize(text_size);
name.setTextSize(text_size * 1.05f);
created_by.setTextSize(text_size * 0.65f);
name.setTextSize(text_size);
screen_name.setTextSize(text_size * 0.75f);
location.setTextSize(text_size);
url.setTextSize(text_size);
statuses_count.setTextSize(text_size);
followers_count.setTextSize(text_size);
friends_count.setTextSize(text_size);
}
public void setUserColor(final int color) {
content.drawStart(color);
}
}

View File

@ -1,428 +0,0 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.view.iface;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable;
import android.os.IBinder;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.View;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.graphic.PaddingDrawable;
import org.mariotaku.twidere.util.ThemeUtils;
public interface ICardItemView extends IColorLabelView {
public View getFakeOverflowButton();
public boolean isGap();
public void setActivatedIndicator(Drawable activatedIndicator);
public void setIsGap(boolean isGap);
public void setItemBackground(Drawable itemBackground);
public void setItemSelector(Drawable itemSelector);
public void setOnOverflowIconClickListener(final OnOverflowIconClickListener listener);
public void setOverflowIcon(Drawable overflowIcon);
public static final class DrawingHelper {
private final View mView;
private final int mCardGapHeight;
private final String mCardGapText;
private final Paint mGapTextPaint;
private final Rect mGapTextBounds = new Rect();
private final Rect mBackgroundPadding = new Rect();
private final Rect mOverflowIconBounds = new Rect();
private Drawable mBackground;
private Drawable mItemSelector;
private Drawable mActivatedIndicator;
private Drawable mOverflowIcon;
private Drawable mPaddedOverflowIcon;
private boolean mIsGap;
private final int mThemeColor;
private final GestureDetector mOverflowIconGestureDetector;
private OnOverflowIconClickListener mOnOverflowIconClickListener;
private final FakeOverflowButton mFakeOverflowButton;
private float mBackgroundAlpha;
public DrawingHelper(final View view, final Context context, final AttributeSet attrs, final int defStyleAttr) {
mView = view;
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CardItemView, defStyleAttr,
R.style.Widget_CardItemView);
mGapTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mCardGapHeight = a.getDimensionPixelSize(R.styleable.CardItemView_cardGapHeight, 0);
mCardGapText = a.getString(R.styleable.CardItemView_cardGapText);
mGapTextPaint.setColor(a.getColor(R.styleable.CardItemView_cardGapTextColor, Color.GRAY));
mGapTextPaint.setTextSize(a.getDimensionPixelSize(R.styleable.CardItemView_cardGapTextSize, 18));
mGapTextPaint.setTypeface(Typeface.DEFAULT_BOLD);
mThemeColor = view.isInEditMode() ? 0 : ThemeUtils.getUserAccentColor(context);
mOverflowIconGestureDetector = new GestureDetector(context, new OverflowIconGestureListener(this));
mFakeOverflowButton = new FakeOverflowButton(this);
mBackgroundAlpha = a.getFraction(R.styleable.CardItemView_cardBackgroundAlpha, 1, 1, 1.0f);
setItemBackground(a.getDrawable(R.styleable.CardItemView_cardBackground));
setItemSelector(a.getDrawable(R.styleable.CardItemView_cardSelector));
setActivatedIndicator(a.getDrawable(R.styleable.CardItemView_cardActivatedIndicator));
setOverflowIcon(a.getDrawable(R.styleable.CardItemView_cardOverflowIcon));
a.recycle();
}
public void dispatchDrawableStateChanged() {
final int[] state = mView.getDrawableState();
if (mBackground != null) {
mBackground.setState(state);
}
if (mItemSelector != null) {
mItemSelector.setState(state);
}
if (mActivatedIndicator != null) {
mActivatedIndicator.setState(state);
}
}
public void dispatchOnSizeChanged(final int w, final int h, final int oldw, final int oldh) {
final int paddingLeft = mView.getPaddingLeft();
final int paddingTop = mView.getPaddingTop();
final int paddingRight = mView.getPaddingRight();
final int paddingBottom = mView.getPaddingBottom();
final int l = paddingLeft, t = paddingTop, r = w - paddingRight, b = h - paddingBottom;
if (mBackground != null) {
if (mBackground instanceof NinePatchDrawable) {
final NinePatchDrawable npd = (NinePatchDrawable) mBackground;
npd.getPadding(mBackgroundPadding);
npd.setBounds(l - mBackgroundPadding.left, t - mBackgroundPadding.top,
r + mBackgroundPadding.right, b + mBackgroundPadding.bottom);
} else {
mBackground.setBounds(l, t, r, b);
}
}
if (mItemSelector != null) {
if (mIsGap) {
mItemSelector.setBounds(0, 0, w, h);
} else {
mItemSelector.setBounds(l, t, r, b);
}
}
if (mActivatedIndicator != null) {
mActivatedIndicator.setBounds(l, t, r, b);
}
if (mOverflowIcon != null) {
mPaddedOverflowIcon = new PaddingDrawable(mOverflowIcon, paddingTop, 0, paddingRight, 0);
final int iw = mPaddedOverflowIcon.getIntrinsicWidth();
final int ih = mPaddedOverflowIcon.getIntrinsicHeight();
mOverflowIconBounds.set(w - iw, 0, w, ih);
mPaddedOverflowIcon.setBounds(mOverflowIconBounds);
} else {
mPaddedOverflowIcon = null;
}
}
public void drawBackground(final Canvas canvas) {
if (mBackground != null && !mIsGap) {
mBackground.draw(canvas);
}
}
public void drawGap(final Canvas canvas) {
if (mIsGap) {
final int centerX = canvas.getWidth() / 2, centerY = canvas.getHeight() / 2;
if (mCardGapText != null) {
mGapTextPaint.getTextBounds(mCardGapText, 0, mCardGapText.length(), mGapTextBounds);
final float xPos = centerX - mGapTextBounds.width() / 2;
final float yPos = centerY - (mGapTextPaint.descent() + mGapTextPaint.ascent()) / 2;
canvas.drawText(mCardGapText, xPos, yPos, mGapTextPaint);
}
}
}
public void drawOverflowIcon(final Canvas canvas) {
if (mPaddedOverflowIcon != null && mOnOverflowIconClickListener != null) {
mPaddedOverflowIcon.draw(canvas);
}
}
public void drawSelector(final Canvas canvas) {
if (mActivatedIndicator != null) {
mActivatedIndicator.draw(canvas);
}
if (mItemSelector != null) {
mItemSelector.draw(canvas);
}
}
public int getCardGapHeight() {
return mCardGapHeight;
}
public View getFakeOverflowButton() {
return mFakeOverflowButton;
}
public boolean handleOverflowTouchEvent(final MotionEvent ev) {
return mOverflowIconGestureDetector.onTouchEvent(ev);
}
public boolean isGap() {
return mIsGap;
}
public boolean isOverflowIconClicked(final MotionEvent ev) {
if (mOverflowIcon == null || mOnOverflowIconClickListener == null) return false;
final int x = Math.round(ev.getX()), y = Math.round(ev.getY());
if (mOverflowIconBounds.contains(x, y)) return true;
return false;
}
public void setActivatedIndicator(final Drawable activatedIndicator) {
preSetDrawable(mActivatedIndicator);
mActivatedIndicator = activatedIndicator;
if (activatedIndicator != null) {
activatedIndicator.setAlpha(0x80);
}
postSetDrawable(activatedIndicator);
}
public void setIsGap(final boolean isGap) {
mIsGap = isGap;
mView.requestLayout();
}
public void setItemBackground(final Drawable itemBackground) {
preSetDrawable(mBackground);
mBackground = itemBackground;
updateBackgroundAlpha();
postSetDrawable(itemBackground);
}
public void setItemBackgroundAlpha(final float alpha) {
mBackgroundAlpha = alpha;
updateBackgroundAlpha();
}
public void setItemSelector(final Drawable itemSelector) {
preSetDrawable(mItemSelector);
mItemSelector = itemSelector;
if (itemSelector != null) {
itemSelector.setAlpha(0x80);
}
postSetDrawable(itemSelector);
}
public void setOnOverflowIconClickListener(final OnOverflowIconClickListener listener) {
mOnOverflowIconClickListener = listener;
}
public void setOverflowIcon(final Drawable overflowIcon) {
preSetDrawable(mOverflowIcon);
mOverflowIcon = overflowIcon;
if (mOverflowIcon != null) {
mOverflowIcon.mutate();
}
postSetDrawable(overflowIcon);
}
public boolean verifyDrawable(final Drawable who) {
return who == mBackground || who == mItemSelector || who == mActivatedIndicator || who == mOverflowIcon;
}
private void postSetDrawable(final Drawable curr) {
mView.setWillNotDraw(verifyDrawable(curr));
if (curr != null) {
if (curr.isStateful()) {
curr.setState(mView.getDrawableState());
}
curr.setCallback(mView);
}
}
private void preSetDrawable(final Drawable prev) {
if (prev != null) {
mView.unscheduleDrawable(prev);
prev.setCallback(null);
}
}
private void updateBackgroundAlpha() {
if (mBackground != null) {
mBackground.setAlpha(Math.round(mBackgroundAlpha * 0xff));
}
}
static class FakeOverflowButton extends View {
private final DrawingHelper mHelper;
public FakeOverflowButton(final DrawingHelper helper) {
super(helper.mView.getContext());
mHelper = helper;
}
@Override
public void getLocationInWindow(final int[] location) {
mHelper.mView.getLocationInWindow(location);
location[0] += mHelper.mOverflowIconBounds.left;
location[1] += mHelper.mOverflowIconBounds.top;
}
@Override
public void getLocationOnScreen(final int[] location) {
mHelper.mView.getLocationOnScreen(location);
location[0] += mHelper.mOverflowIconBounds.left;
location[1] += mHelper.mOverflowIconBounds.top;
}
@Override
public View getRootView() {
return mHelper.mView.getRootView();
}
@Override
public Object getTag() {
return mHelper.mView.getTag();
}
@Override
public IBinder getWindowToken() {
return mHelper.mView.getWindowToken();
}
@Override
public void getWindowVisibleDisplayFrame(final Rect outRect) {
mHelper.mView.getWindowVisibleDisplayFrame(outRect);
}
@Override
protected void onLayout(final boolean changed, final int left, final int top, final int right,
final int bottom) {
final Rect bounds = mHelper.mOverflowIconBounds;
layout(bounds.left, bounds.top, bounds.right, bounds.bottom);
}
@Override
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
final int width = mHelper.mOverflowIconBounds.width();
final int height = mHelper.mOverflowIconBounds.height();
final int wSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.getMode(widthMeasureSpec));
final int hSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.getMode(heightMeasureSpec));
setMeasuredDimension(width, height);
super.onMeasure(wSpec, hSpec);
}
}
static class OverflowIconGestureListener extends SimpleOnGestureListener {
private final DrawingHelper mDrawingHelper;
public OverflowIconGestureListener(final DrawingHelper drawingHelper) {
mDrawingHelper = drawingHelper;
}
@Override
public boolean onDown(final MotionEvent e) {
final Drawable d = mDrawingHelper.mPaddedOverflowIcon;
final OnOverflowIconClickListener l = mDrawingHelper.mOnOverflowIconClickListener;
if (d == null || l == null) return false;
return true;
}
@Override
public boolean onFling(final MotionEvent e1, final MotionEvent e2, final float velocityX,
final float velocityY) {
return clearHighlight();
}
@Override
public void onLongPress(final MotionEvent e) {
clearHighlight();
}
@Override
public boolean onScroll(final MotionEvent e1, final MotionEvent e2, final float distanceX,
final float distanceY) {
return clearHighlight();
}
@Override
public void onShowPress(final MotionEvent e) {
final Drawable d = mDrawingHelper.mPaddedOverflowIcon;
final int c = mDrawingHelper.mThemeColor;
if (d != null) {
d.setColorFilter(c, PorterDuff.Mode.SRC_ATOP);
}
}
@Override
public boolean onSingleTapConfirmed(final MotionEvent e) {
final OnOverflowIconClickListener l = mDrawingHelper.mOnOverflowIconClickListener;
if (clearHighlight() && l != null) {
l.onOverflowIconClick(mDrawingHelper.mFakeOverflowButton);
}
return false;
}
@Override
public boolean onSingleTapUp(final MotionEvent e) {
return clearHighlight();
}
private boolean clearHighlight() {
final Drawable d = mDrawingHelper.mPaddedOverflowIcon;
if (d != null) {
d.clearColorFilter();
return true;
}
return false;
}
}
}
public static interface OnOverflowIconClickListener {
public void onOverflowIconClick(View view);
}
}

View File

@ -8,7 +8,7 @@ public interface TranslationResult extends TwitterResponse {
public String getText();
public String getTranslatedLong();
public String getTranslatedLang();
public String getTranslationType();

View File

@ -69,7 +69,7 @@ public class TranslationResultJSONImpl extends TwitterResponseImpl implements Tr
}
@Override
public String getTranslatedLong() {
public String getTranslatedLang() {
return translatedLang;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 177 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 446 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 777 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 177 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 268 B

View File

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:duration="70">
<bitmap
android:antialias="false"
android:filter="false"
android:src="@drawable/nyan_sakamoto_santa_frame00"/>
</item>
<item android:duration="70">
<bitmap
android:antialias="false"
android:filter="false"
android:src="@drawable/nyan_sakamoto_santa_frame01"/>
</item>
<item android:duration="70">
<bitmap
android:antialias="false"
android:filter="false"
android:src="@drawable/nyan_sakamoto_santa_frame02"/>
</item>
<item android:duration="70">
<bitmap
android:antialias="false"
android:filter="false"
android:src="@drawable/nyan_sakamoto_santa_frame03"/>
</item>
<item android:duration="70">
<bitmap
android:antialias="false"
android:filter="false"
android:src="@drawable/nyan_sakamoto_santa_frame04"/>
</item>
<item android:duration="70">
<bitmap
android:antialias="false"
android:filter="false"
android:src="@drawable/nyan_sakamoto_santa_frame05"/>
</item>
<item android:duration="70">
<bitmap
android:antialias="false"
android:filter="false"
android:src="@drawable/nyan_sakamoto_santa_frame06"/>
</item>
<item android:duration="70">
<bitmap
android:antialias="false"
android:filter="false"
android:src="@drawable/nyan_sakamoto_santa_frame07"/>
</item>
<item android:duration="70">
<bitmap
android:antialias="false"
android:filter="false"
android:src="@drawable/nyan_sakamoto_santa_frame08"/>
</item>
<item android:duration="70">
<bitmap
android:antialias="false"
android:filter="false"
android:src="@drawable/nyan_sakamoto_santa_frame09"/>
</item>
<item android:duration="70">
<bitmap
android:antialias="false"
android:filter="false"
android:src="@drawable/nyan_sakamoto_santa_frame10"/>
</item>
<item android:duration="70">
<bitmap
android:antialias="false"
android:filter="false"
android:src="@drawable/nyan_sakamoto_santa_frame11"/>
</item>
</animation-list>

View File

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states -->
<item android:drawable="@android:color/transparent" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/>
<item android:drawable="@drawable/tab_vpi_selected_nocolor_holo" android:state_focused="false" android:state_pressed="false" android:state_selected="true"/>
<!-- Focused states -->
<item android:drawable="@drawable/tab_vpi_unselected_focused_nocolor_holo" android:state_focused="true" android:state_pressed="false" android:state_selected="false"/>
<item android:drawable="@drawable/tab_vpi_selected_focused_nocolor_holo" android:state_focused="true" android:state_pressed="false" android:state_selected="true"/>
<!-- Pressed -->
<!-- Non focused states -->
<item android:drawable="@drawable/tab_vpi_unselected_pressed_nocolor_holo" android:state_focused="false" android:state_pressed="true" android:state_selected="false"/>
<item android:drawable="@drawable/tab_vpi_selected_pressed_nocolor_holo" android:state_focused="false" android:state_pressed="true" android:state_selected="true"/>
<!-- Focused states -->
<item android:drawable="@drawable/tab_vpi_unselected_pressed_nocolor_holo" android:state_focused="true" android:state_pressed="true" android:state_selected="false"/>
<item android:drawable="@drawable/tab_vpi_selected_pressed_nocolor_holo" android:state_focused="true" android:state_pressed="true" android:state_selected="true"/>
</selector>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<org.mariotaku.twidere.view.CardItemLinearLayout
<org.mariotaku.twidere.view.ColorLabelLinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content"
android:layout_width="match_parent"
@ -201,4 +201,4 @@
android:textStyle="bold"/>
</LinearLayout>
</org.mariotaku.twidere.view.CardItemLinearLayout>
</org.mariotaku.twidere.view.ColorLabelLinearLayout>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<org.mariotaku.twidere.view.CardItemFrameLayout
<org.mariotaku.twidere.view.ColorLabelFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content"
android:layout_width="match_parent"
@ -213,4 +213,4 @@
</LinearLayout>
</RelativeLayout>
</org.mariotaku.twidere.view.CardItemFrameLayout>
</org.mariotaku.twidere.view.ColorLabelFrameLayout>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<org.mariotaku.twidere.view.CardItemLinearLayout
<org.mariotaku.twidere.view.ColorLabelLinearLayout
android:id="@+id/content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
@ -79,4 +79,4 @@
android:layout_height="wrap_content"
android:text="@string/send"/>
</LinearLayout>
</org.mariotaku.twidere.view.CardItemLinearLayout>
</org.mariotaku.twidere.view.ColorLabelLinearLayout>

View File

@ -1,131 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>
<org.mariotaku.twidere.view.CardItemLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/element_spacing_small"
android:paddingLeft="@dimen/element_spacing_normal"
android:paddingRight="@dimen/element_spacing_normal"
android:paddingTop="@dimen/element_spacing_small"
tools:context=".adapter.ParcelableUsersAdapter">
<org.mariotaku.twidere.view.ColorLabelLinearLayout
android:id="@+id/content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/element_spacing_small"
android:paddingLeft="@dimen/element_spacing_normal"
android:paddingRight="@dimen/element_spacing_normal"
android:paddingTop="@dimen/element_spacing_small"
tools:context=".adapter.ParcelableUsersAdapter">
<LinearLayout
android:id="@+id/profile_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingBottom="@dimen/element_spacing_normal"
android:paddingLeft="@dimen/element_spacing_normal"
android:paddingRight="@dimen/element_spacing_xlarge"
android:paddingTop="@dimen/element_spacing_normal">
<RelativeLayout
android:id="@+id/profile_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/element_spacing_normal"
android:paddingLeft="@dimen/element_spacing_normal"
android:paddingRight="@dimen/element_spacing_xlarge"
android:paddingTop="@dimen/element_spacing_normal">
<org.mariotaku.twidere.view.CircularImageView
android:id="@+id/profile_image"
android:layout_width="@dimen/icon_size_card_list_item"
android:layout_height="@dimen/icon_size_card_list_item"
android:layout_weight="0"
android:contentDescription="@string/profile_image"
android:scaleType="fitCenter"/>
<org.mariotaku.twidere.view.CircularImageView
android:id="@+id/profile_image"
android:layout_width="@dimen/icon_size_card_list_item"
android:layout_height="@dimen/icon_size_card_list_item"
android:layout_centerVertical="true"
android:contentDescription="@string/profile_image"
android:scaleType="fitCenter"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingLeft="8dp">
<ImageView
android:id="@+id/profile_type"
android:layout_width="@dimen/icon_size_profile_type"
android:layout_height="@dimen/icon_size_profile_type"
android:layout_alignBottom="@id/profile_image"
android:layout_alignRight="@id/profile_image"
android:layout_marginBottom="@dimen/element_spacing_minus_small"
android:layout_marginRight="@dimen/element_spacing_minus_normal"
android:scaleType="centerInside"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary"
android:textStyle="bold"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/profile_image"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingLeft="8dp">
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/screen_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/>
</LinearLayout>
</LinearLayout>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary"
android:textStyle="bold"/>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="0.2dp"
android:background="#40808080"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/screen_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/>
</LinearLayout>
</RelativeLayout>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="0.2dp"
android:background="#40808080"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_indicator_location"
android:drawablePadding="4dp"
android:padding="8dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_indicator_web"
android:drawablePadding="4dp"
android:padding="8dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_indicator_location"
android:drawablePadding="4dp"
android:padding="8dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp">
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_indicator_web"
android:drawablePadding="4dp"
android:padding="8dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/statuses_count"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="@drawable/ic_indicator_twitter"
android:drawablePadding="4dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp">
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/followers_count"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="@drawable/ic_indicator_followers"
android:drawablePadding="4dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/statuses_count"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="@drawable/ic_indicator_twitter"
android:drawablePadding="4dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/friends_count"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="@drawable/ic_indicator_following"
android:drawablePadding="4dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"/>
</LinearLayout>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/followers_count"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="@drawable/ic_indicator_followers"
android:drawablePadding="4dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"/>
</org.mariotaku.twidere.view.CardItemLinearLayout>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/friends_count"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableLeft="@drawable/ic_indicator_following"
android:drawablePadding="4dp"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"/>
</LinearLayout>
</org.mariotaku.twidere.view.ColorLabelLinearLayout>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<org.mariotaku.twidere.view.CardItemFrameLayout
<org.mariotaku.twidere.view.ColorLabelFrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content"
@ -29,6 +29,16 @@
android:contentDescription="@string/profile_image"
android:scaleType="fitCenter"/>
<ImageView
android:id="@+id/profile_type"
android:layout_width="@dimen/icon_size_profile_type"
android:layout_height="@dimen/icon_size_profile_type"
android:layout_alignBottom="@id/profile_image"
android:layout_alignRight="@id/profile_image"
android:layout_marginBottom="@dimen/element_spacing_minus_small"
android:layout_marginRight="@dimen/element_spacing_minus_normal"
android:scaleType="centerInside"/>
<FrameLayout
android:id="@+id/name_frame"
android:layout_width="wrap_content"
@ -141,4 +151,4 @@
</LinearLayout>
</RelativeLayout>
</org.mariotaku.twidere.view.CardItemFrameLayout>
</org.mariotaku.twidere.view.ColorLabelFrameLayout>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<org.mariotaku.twidere.view.CardItemLinearLayout
<org.mariotaku.twidere.view.ColorLabelLinearLayout
android:id="@+id/content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
@ -100,4 +100,4 @@
android:textAppearance="?android:attr/textAppearanceSmall"/>
</LinearLayout>
</org.mariotaku.twidere.view.CardItemLinearLayout>
</org.mariotaku.twidere.view.ColorLabelLinearLayout>

Some files were not shown because too many files have changed in this diff Show More