improved some preferences

This commit is contained in:
Mariotaku Lee 2015-04-09 00:33:10 +08:00
parent be7dffff16
commit 3babd63c0f
26 changed files with 575 additions and 557 deletions

View File

@ -309,4 +309,6 @@ public interface SharedPreferenceConstants {
String KEY_THUMBOR_ENABLED = "thumbor_enabled";
String KEY_THUMBOR_ADDRESS = "thumbor_address";
String KEY_THUMBOR_SECURITY_KEY = "thumbor_security_key";
@Preference(type = BOOLEAN, hasDefault = true, defaultBoolean = false)
String KEY_HIDE_CARD_ACTIONS = "hide_card_actions";
}

View File

@ -48,6 +48,10 @@ public abstract class AbsStatusesAdapter<D> extends Adapter<ViewHolder> implemen
private final MediaLoaderWrapper mImageLoader;
private final ImageLoadingHandler mLoadingHandler;
private final AsyncTwitterWrapper mTwitterWrapper;
private final TwidereLinkify mLinkify;
private StatusAdapterListener mStatusAdapterListener;
private final int mCardBackgroundColor;
private final int mTextSize;
@ShapeStyle
@ -62,11 +66,10 @@ public abstract class AbsStatusesAdapter<D> extends Adapter<ViewHolder> implemen
private final boolean mDisplayMediaPreview;
private final boolean mDisplayProfileImage;
private final boolean mSensitiveContentEnabled;
private final TwidereLinkify mLinkify;
private final boolean mHideCardActions;
private boolean mLoadMoreSupported;
private boolean mLoadMoreIndicatorVisible;
private StatusAdapterListener mStatusAdapterListener;
private boolean mShowInReplyTo;
private boolean mShowAccountsColor;
@ -89,6 +92,7 @@ public abstract class AbsStatusesAdapter<D> extends Adapter<ViewHolder> implemen
mDisplayProfileImage = preferences.getBoolean(KEY_DISPLAY_PROFILE_IMAGE, true);
mDisplayMediaPreview = preferences.getBoolean(KEY_MEDIA_PREVIEW, false);
mSensitiveContentEnabled = preferences.getBoolean(KEY_DISPLAY_SENSITIVE_CONTENTS, false);
mHideCardActions = preferences.getBoolean(KEY_HIDE_CARD_ACTIONS, false);
mLinkify = new TwidereLinkify(new StatusAdapterLinkClickHandler<>(this));
setShowInReplyTo(true);
}
@ -188,6 +192,11 @@ public abstract class AbsStatusesAdapter<D> extends Adapter<ViewHolder> implemen
return mSensitiveContentEnabled;
}
@Override
public boolean isCardActionsHidden() {
return mHideCardActions;
}
@Override
public boolean isProfileImageEnabled() {
return mDisplayProfileImage;

View File

@ -25,6 +25,8 @@ public interface IStatusesAdapter<Data> extends IContentCardAdapter, StatusClick
boolean isSensitiveContentEnabled();
boolean isCardActionsHidden();
void setData(Data data);
boolean shouldShowAccountsColor();

View File

@ -268,9 +268,6 @@ public class SearchFragment extends BaseSupportFragment implements RefreshScroll
return true;
}
public void showIndicator() {
}
@Override
public boolean triggerRefresh() {
if (!(mCurrentVisibleFragment instanceof RefreshScrollTopInterface)) return false;

View File

@ -1011,6 +1011,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
private final boolean mDisplayMediaPreview;
private final boolean mDisplayProfileImage;
private final boolean mSensitiveContentEnabled;
private final boolean mHideCardActions;
private boolean mLoadMoreSupported;
private boolean mLoadMoreIndicatorVisible;
@ -1042,6 +1043,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
mDisplayProfileImage = preferences.getBoolean(KEY_DISPLAY_PROFILE_IMAGE, true);
mDisplayMediaPreview = preferences.getBoolean(KEY_MEDIA_PREVIEW, false);
mSensitiveContentEnabled = preferences.getBoolean(KEY_DISPLAY_SENSITIVE_CONTENTS, false);
mHideCardActions = preferences.getBoolean(KEY_HIDE_CARD_ACTIONS, false);
if (compact) {
mCardLayoutResource = R.layout.card_item_status_compact;
} else {
@ -1177,6 +1179,11 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
return mSensitiveContentEnabled;
}
@Override
public boolean isCardActionsHidden() {
return mHideCardActions;
}
@Override
public void setData(List<ParcelableStatus> data) {

View File

@ -90,6 +90,7 @@ import org.mariotaku.twidere.activity.support.UserProfileEditorActivity;
import org.mariotaku.twidere.adapter.support.SupportTabsAdapter;
import org.mariotaku.twidere.app.TwidereApplication;
import org.mariotaku.twidere.fragment.iface.IBaseFragment.SystemWindowsInsetsCallback;
import org.mariotaku.twidere.fragment.iface.RefreshScrollTopInterface;
import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback;
import org.mariotaku.twidere.graphic.ActionBarColorDrawable;
import org.mariotaku.twidere.graphic.ActionIconDrawable;
@ -166,7 +167,8 @@ import static org.mariotaku.twidere.util.Utils.showInfoMessage;
public class UserFragment extends BaseSupportFragment implements OnClickListener,
OnLinkClickListener, OnSizeChangedListener, OnSharedPreferenceChangeListener,
OnTouchListener, DrawerCallback, SupportFragmentCallback, SystemWindowsInsetsCallback {
OnTouchListener, DrawerCallback, SupportFragmentCallback, SystemWindowsInsetsCallback,
RefreshScrollTopInterface {
public static final String TRANSITION_NAME_PROFILE_IMAGE = "profile_image";
public static final String TRANSITION_NAME_PROFILE_TYPE = "profile_type";
@ -174,9 +176,8 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
private static final int LOADER_ID_USER = 1;
private static final int LOADER_ID_FRIENDSHIP = 2;
private static final ArgbEvaluator sArgbEvaluator = new ArgbEvaluator();
private MediaLoaderWrapper mProfileImageLoader;
private ShapedImageView mProfileImageView;
private ImageView mProfileTypeView;
private ProfileBannerImageView mProfileBannerView;
@ -202,109 +203,20 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
private TextView mPagesErrorText;
private View mProfileNameBackground;
private View mProfileDetailsContainer;
private SupportTabsAdapter mPagerAdapter;
private Relationship mRelationship;
private ParcelableUser mUser = null;
private ParcelableUser mUser = null;
private Locale mLocale;
private boolean mGetUserInfoLoaderInitialized, mGetFriendShipLoaderInitialized;
private int mBannerWidth;
private ActionBarDrawable mActionBarBackground;
private Fragment mCurrentVisibleFragment;
private int mCardBackgroundColor;
private int mUserUiColor;
private ActionBarDrawable mActionBarBackground;
private Fragment mCurrentVisibleFragment;
@Subscribe
public void notifyTaskStateChanged(TaskStateChangedEvent event) {
updateRefreshState();
}
@Subscribe
public void notifyFriendshipUpdated(FriendshipUpdatedEvent event) {
if (!event.user.equals(mUser)) return;
getFriendship();
}
private void updateRefreshState() {
final ParcelableUser user = getUser();
if (user == null) return;
final AsyncTwitterWrapper twitter = getTwitterWrapper();
final boolean is_creating_friendship = twitter != null
&& twitter.isCreatingFriendship(user.account_id, user.id);
final boolean is_destroying_friendship = twitter != null
&& twitter.isDestroyingFriendship(user.account_id, user.id);
setProgressBarIndeterminateVisibility(is_creating_friendship || is_destroying_friendship);
invalidateOptionsMenu();
}
private final LoaderCallbacks<SingleResponse<ParcelableUser>> mUserInfoLoaderCallbacks = new LoaderCallbacks<SingleResponse<ParcelableUser>>() {
@Override
public Loader<SingleResponse<ParcelableUser>> onCreateLoader(final int id, final Bundle args) {
final boolean omitIntentExtra = args.getBoolean(EXTRA_OMIT_INTENT_EXTRA, true);
final long accountId = args.getLong(EXTRA_ACCOUNT_ID, -1);
final long userId = args.getLong(EXTRA_USER_ID, -1);
final String screenName = args.getString(EXTRA_SCREEN_NAME);
if (mUser == null && (!omitIntentExtra || !args.containsKey(EXTRA_USER))) {
mCardContent.setVisibility(View.GONE);
mErrorRetryContainer.setVisibility(View.GONE);
mProgressContainer.setVisibility(View.VISIBLE);
mErrorMessageView.setText(null);
mErrorMessageView.setVisibility(View.GONE);
setListShown(false);
}
setProgressBarIndeterminateVisibility(true);
final ParcelableUser user = mUser;
return new ParcelableUserLoader(getActivity(), accountId, userId, screenName, getArguments(),
omitIntentExtra, user == null || !user.is_cache && userId != user.id);
}
@Override
public void onLoaderReset(final Loader<SingleResponse<ParcelableUser>> loader) {
}
@Override
public void onLoadFinished(final Loader<SingleResponse<ParcelableUser>> loader,
final SingleResponse<ParcelableUser> data) {
if (getActivity() == null) return;
if (data.hasData()) {
final ParcelableUser user = data.getData();
mCardContent.setVisibility(View.VISIBLE);
mErrorRetryContainer.setVisibility(View.GONE);
mProgressContainer.setVisibility(View.GONE);
setListShown(true);
displayUser(user);
if (user.is_cache) {
final Bundle args = new Bundle();
args.putLong(EXTRA_ACCOUNT_ID, user.account_id);
args.putLong(EXTRA_USER_ID, user.id);
args.putString(EXTRA_SCREEN_NAME, user.screen_name);
args.putBoolean(EXTRA_OMIT_INTENT_EXTRA, true);
getLoaderManager().restartLoader(LOADER_ID_USER, args, this);
}
} else if (mUser != null && mUser.is_cache) {
mCardContent.setVisibility(View.VISIBLE);
mErrorRetryContainer.setVisibility(View.GONE);
mProgressContainer.setVisibility(View.GONE);
setListShown(true);
displayUser(mUser);
} else {
if (data.hasException()) {
mErrorMessageView.setText(getErrorMessage(getActivity(), data.getException()));
mErrorMessageView.setVisibility(View.VISIBLE);
}
mCardContent.setVisibility(View.GONE);
mErrorRetryContainer.setVisibility(View.VISIBLE);
mProgressContainer.setVisibility(View.GONE);
}
setProgressBarIndeterminateVisibility(false);
}
};
private final LoaderCallbacks<SingleResponse<Relationship>> mFriendshipLoaderCallbacks = new LoaderCallbacks<SingleResponse<Relationship>>() {
@Override
@ -402,6 +314,132 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
};
private final LoaderCallbacks<SingleResponse<ParcelableUser>> mUserInfoLoaderCallbacks = new LoaderCallbacks<SingleResponse<ParcelableUser>>() {
@Override
public Loader<SingleResponse<ParcelableUser>> onCreateLoader(final int id, final Bundle args) {
final boolean omitIntentExtra = args.getBoolean(EXTRA_OMIT_INTENT_EXTRA, true);
final long accountId = args.getLong(EXTRA_ACCOUNT_ID, -1);
final long userId = args.getLong(EXTRA_USER_ID, -1);
final String screenName = args.getString(EXTRA_SCREEN_NAME);
if (mUser == null && (!omitIntentExtra || !args.containsKey(EXTRA_USER))) {
mCardContent.setVisibility(View.GONE);
mErrorRetryContainer.setVisibility(View.GONE);
mProgressContainer.setVisibility(View.VISIBLE);
mErrorMessageView.setText(null);
mErrorMessageView.setVisibility(View.GONE);
setListShown(false);
}
setProgressBarIndeterminateVisibility(true);
final ParcelableUser user = mUser;
return new ParcelableUserLoader(getActivity(), accountId, userId, screenName, getArguments(),
omitIntentExtra, user == null || !user.is_cache && userId != user.id);
}
@Override
public void onLoaderReset(final Loader<SingleResponse<ParcelableUser>> loader) {
}
@Override
public void onLoadFinished(final Loader<SingleResponse<ParcelableUser>> loader,
final SingleResponse<ParcelableUser> data) {
if (getActivity() == null) return;
if (data.hasData()) {
final ParcelableUser user = data.getData();
mCardContent.setVisibility(View.VISIBLE);
mErrorRetryContainer.setVisibility(View.GONE);
mProgressContainer.setVisibility(View.GONE);
setListShown(true);
displayUser(user);
if (user.is_cache) {
final Bundle args = new Bundle();
args.putLong(EXTRA_ACCOUNT_ID, user.account_id);
args.putLong(EXTRA_USER_ID, user.id);
args.putString(EXTRA_SCREEN_NAME, user.screen_name);
args.putBoolean(EXTRA_OMIT_INTENT_EXTRA, true);
getLoaderManager().restartLoader(LOADER_ID_USER, args, this);
}
} else if (mUser != null && mUser.is_cache) {
mCardContent.setVisibility(View.VISIBLE);
mErrorRetryContainer.setVisibility(View.GONE);
mProgressContainer.setVisibility(View.GONE);
setListShown(true);
displayUser(mUser);
} else {
if (data.hasException()) {
mErrorMessageView.setText(getErrorMessage(getActivity(), data.getException()));
mErrorMessageView.setVisibility(View.VISIBLE);
}
mCardContent.setVisibility(View.GONE);
mErrorRetryContainer.setVisibility(View.VISIBLE);
mProgressContainer.setVisibility(View.GONE);
}
setProgressBarIndeterminateVisibility(false);
}
};
@Override
public boolean canScroll(float dy) {
final Fragment fragment = mCurrentVisibleFragment;
return fragment instanceof DrawerCallback && ((DrawerCallback) fragment).canScroll(dy);
}
@Override
public void cancelTouch() {
final Fragment fragment = mCurrentVisibleFragment;
if (fragment instanceof DrawerCallback) {
((DrawerCallback) fragment).cancelTouch();
}
}
@Override
public void fling(float velocity) {
final Fragment fragment = mCurrentVisibleFragment;
if (fragment instanceof DrawerCallback) {
((DrawerCallback) fragment).fling(velocity);
}
}
@Override
public boolean isScrollContent(float x, float y) {
final ViewPager v = mViewPager;
final int[] location = new int[2];
v.getLocationOnScreen(location);
return x >= location[0] && x <= location[0] + v.getWidth()
&& y >= location[1] && y <= location[1] + v.getHeight();
}
@Override
public void scrollBy(float dy) {
final Fragment fragment = mCurrentVisibleFragment;
if (fragment instanceof DrawerCallback) {
((DrawerCallback) fragment).scrollBy(dy);
}
}
@Override
public boolean shouldLayoutHeaderBottom() {
final HeaderDrawerLayout drawer = mHeaderDrawerLayout;
final View card = mProfileDetailsContainer;
if (drawer == null || card == null) return false;
return card.getTop() + drawer.getHeaderTop() - drawer.getPaddingTop() <= 0;
}
@Override
public void topChanged(int top) {
final HeaderDrawerLayout drawer = mHeaderDrawerLayout;
if (drawer == null) return;
final int offset = drawer.getPaddingTop() - top;
updateScrollOffset(offset);
final Fragment fragment = mCurrentVisibleFragment;
if (fragment instanceof DrawerCallback) {
((DrawerCallback) fragment).topChanged(top);
}
}
public void displayUser(final ParcelableUser user) {
mUser = user;
final FragmentActivity activity = getActivity();
@ -468,66 +506,6 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
invalidateOptionsMenu();
}
@Override
public void fling(float velocity) {
final Fragment fragment = mCurrentVisibleFragment;
if (fragment instanceof DrawerCallback) {
((DrawerCallback) fragment).fling(velocity);
}
}
@Override
public void scrollBy(float dy) {
final Fragment fragment = mCurrentVisibleFragment;
if (fragment instanceof DrawerCallback) {
((DrawerCallback) fragment).scrollBy(dy);
}
}
@Override
public boolean canScroll(float dy) {
final Fragment fragment = mCurrentVisibleFragment;
return fragment instanceof DrawerCallback && ((DrawerCallback) fragment).canScroll(dy);
}
@Override
public boolean isScrollContent(float x, float y) {
final ViewPager v = mViewPager;
final int[] location = new int[2];
v.getLocationOnScreen(location);
return x >= location[0] && x <= location[0] + v.getWidth()
&& y >= location[1] && y <= location[1] + v.getHeight();
}
@Override
public void cancelTouch() {
final Fragment fragment = mCurrentVisibleFragment;
if (fragment instanceof DrawerCallback) {
((DrawerCallback) fragment).cancelTouch();
}
}
@Override
public void topChanged(int top) {
final HeaderDrawerLayout drawer = mHeaderDrawerLayout;
if (drawer == null) return;
final int offset = drawer.getPaddingTop() - top;
updateScrollOffset(offset);
final Fragment fragment = mCurrentVisibleFragment;
if (fragment instanceof DrawerCallback) {
((DrawerCallback) fragment).topChanged(top);
}
}
@Override
public boolean shouldLayoutHeaderBottom() {
final HeaderDrawerLayout drawer = mHeaderDrawerLayout;
final View card = mProfileDetailsContainer;
if (drawer == null || card == null) return false;
return card.getTop() + drawer.getHeaderTop() - drawer.getPaddingTop() <= 0;
}
@Override
public Fragment getCurrentVisibleFragment() {
return mCurrentVisibleFragment;
@ -553,6 +531,10 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
return false;
}
public ParcelableUser getUser() {
return mUser;
}
public void getUserInfo(final long accountId, final long userId, final String screenName,
final boolean omitIntentExtra) {
final LoaderManager lm = getLoaderManager();
@ -575,6 +557,24 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
}
}
@Subscribe
public void notifyFriendshipUpdated(FriendshipUpdatedEvent event) {
if (!event.user.equals(mUser)) return;
getFriendship();
}
@Subscribe
public void notifyProfileUpdated(ProfileUpdatedEvent event) {
final ParcelableUser user = getUser();
if (user == null || !user.equals(event.user)) return;
displayUser(event.user);
}
@Subscribe
public void notifyTaskStateChanged(TaskStateChangedEvent event) {
updateRefreshState();
}
@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
final ParcelableUser user = getUser();
@ -632,7 +632,6 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
return view;
}
@Override
public void onActivityCreated(final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
@ -670,20 +669,6 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
activity.setEnterSharedElementCallback(new SharedElementCallback() {
@Override
public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
int idx = sharedElementNames.indexOf(TRANSITION_NAME_PROFILE_IMAGE);
if (idx != -1) {
final View view = sharedElements.get(idx);
int[] location = new int[2];
final RectF bounds = new RectF(0, 0, view.getWidth(), view.getHeight());
view.getLocationOnScreen(location);
bounds.offsetTo(location[0], location[1]);
mProfileImageView.setTransitionDestination(bounds);
}
super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots);
}
@Override
public void onSharedElementStart(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
final int idx = sharedElementNames.indexOf(TRANSITION_NAME_PROFILE_IMAGE);
@ -698,6 +683,20 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
super.onSharedElementStart(sharedElementNames, sharedElements, sharedElementSnapshots);
}
@Override
public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
int idx = sharedElementNames.indexOf(TRANSITION_NAME_PROFILE_IMAGE);
if (idx != -1) {
final View view = sharedElements.get(idx);
int[] location = new int[2];
final RectF bounds = new RectF(0, 0, view.getWidth(), view.getHeight());
view.getLocationOnScreen(location);
bounds.offsetTo(location[0], location[1]);
mProfileImageView.setTransitionDestination(bounds);
}
super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots);
}
});
ViewCompat.setTransitionName(mProfileImageView, TRANSITION_NAME_PROFILE_IMAGE);
@ -746,16 +745,10 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
bus.register(this);
}
@Subscribe
public void notifyProfileUpdated(ProfileUpdatedEvent event) {
final ParcelableUser user = getUser();
if (user == null || !user.equals(event.user)) return;
displayUser(event.user);
}
public ParcelableUser getUser() {
return mUser;
@Override
public void onSaveInstanceState(final Bundle outState) {
outState.putParcelable(EXTRA_USER, getUser());
super.onSaveInstanceState(outState);
}
@Override
@ -765,12 +758,6 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
super.onStop();
}
@Override
public void onSaveInstanceState(final Bundle outState) {
outState.putParcelable(EXTRA_USER, getUser());
super.onSaveInstanceState(outState);
}
@Override
public void onDestroyView() {
mUser = null;
@ -989,6 +976,66 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
return true;
}
@Override
public void onBaseViewCreated(final View view, final Bundle savedInstanceState) {
super.onBaseViewCreated(view, savedInstanceState);
mHeaderDrawerLayout = (HeaderDrawerLayout) view.findViewById(R.id.user_profile_drawer);
final View headerView = mHeaderDrawerLayout.getHeader();
final View contentView = mHeaderDrawerLayout.getContent();
mCardContent = headerView.findViewById(R.id.card_content);
mErrorRetryContainer = headerView.findViewById(R.id.error_retry_container);
mProgressContainer = headerView.findViewById(R.id.progress_container);
mRetryButton = (Button) headerView.findViewById(R.id.retry);
mErrorMessageView = (TextView) headerView.findViewById(R.id.error_message);
mProfileBannerView = (ProfileBannerImageView) view.findViewById(R.id.profile_banner);
mProfileBannerContainer = view.findViewById(R.id.profile_banner_container);
mNameView = (TextView) headerView.findViewById(R.id.name);
mScreenNameView = (TextView) headerView.findViewById(R.id.screen_name);
mDescriptionView = (TextView) headerView.findViewById(R.id.description);
mLocationView = (TextView) headerView.findViewById(R.id.location);
mURLView = (TextView) headerView.findViewById(R.id.url);
mCreatedAtView = (TextView) headerView.findViewById(R.id.created_at);
mListedContainer = headerView.findViewById(R.id.listed_container);
mListedCount = (TextView) headerView.findViewById(R.id.listed_count);
mFollowersContainer = headerView.findViewById(R.id.followers_container);
mFollowersCount = (TextView) headerView.findViewById(R.id.followers_count);
mFriendsContainer = headerView.findViewById(R.id.friends_container);
mFriendsCount = (TextView) headerView.findViewById(R.id.friends_count);
mProfileNameContainer = (ColorLabelRelativeLayout) headerView.findViewById(R.id.profile_name_container);
mProfileImageView = (ShapedImageView) headerView.findViewById(R.id.profile_image);
mProfileTypeView = (ImageView) headerView.findViewById(R.id.profile_type);
mDescriptionContainer = headerView.findViewById(R.id.description_container);
mLocationContainer = headerView.findViewById(R.id.location_container);
mURLContainer = headerView.findViewById(R.id.url_container);
mProfileBannerSpace = headerView.findViewById(R.id.profile_banner_space);
mViewPager = (ViewPager) contentView.findViewById(R.id.view_pager);
mPagerIndicator = (TabPagerIndicator) contentView.findViewById(R.id.view_pager_tabs);
mFollowButton = (Button) headerView.findViewById(R.id.follow);
mFollowProgress = (ProgressBar) headerView.findViewById(R.id.follow_progress);
mUuckyFooter = headerView.findViewById(R.id.uucky_footer);
mPagesContent = view.findViewById(R.id.pages_content);
mPagesErrorContainer = view.findViewById(R.id.pages_error_container);
mPagesErrorIcon = (ImageView) view.findViewById(R.id.pages_error_icon);
mPagesErrorText = (TextView) view.findViewById(R.id.pages_error_text);
mProfileNameBackground = view.findViewById(R.id.profile_name_background);
mProfileDetailsContainer = view.findViewById(R.id.profile_details_container);
}
@Override
protected void fitSystemWindows(Rect insets) {
super.fitSystemWindows(insets);
mHeaderDrawerLayout.setPadding(insets.left, insets.top, insets.right, insets.bottom);
final FragmentActivity activity = getActivity();
final boolean isTransparentBackground;
if (activity instanceof IThemedActivity) {
final int themeRes = ((IThemedActivity) activity).getCurrentThemeResourceId();
isTransparentBackground = ThemeUtils.isTransparentBackground(themeRes);
} else {
isTransparentBackground = ThemeUtils.isTransparentBackground(getActivity());
}
mHeaderDrawerLayout.setClipToPadding(isTransparentBackground);
}
@Override
public void onClick(final View view) {
final FragmentActivity activity = getActivity();
@ -1115,63 +1162,17 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
}
@Override
public void onBaseViewCreated(final View view, final Bundle savedInstanceState) {
super.onBaseViewCreated(view, savedInstanceState);
mHeaderDrawerLayout = (HeaderDrawerLayout) view.findViewById(R.id.user_profile_drawer);
final View headerView = mHeaderDrawerLayout.getHeader();
final View contentView = mHeaderDrawerLayout.getContent();
mCardContent = headerView.findViewById(R.id.card_content);
mErrorRetryContainer = headerView.findViewById(R.id.error_retry_container);
mProgressContainer = headerView.findViewById(R.id.progress_container);
mRetryButton = (Button) headerView.findViewById(R.id.retry);
mErrorMessageView = (TextView) headerView.findViewById(R.id.error_message);
mProfileBannerView = (ProfileBannerImageView) view.findViewById(R.id.profile_banner);
mProfileBannerContainer = view.findViewById(R.id.profile_banner_container);
mNameView = (TextView) headerView.findViewById(R.id.name);
mScreenNameView = (TextView) headerView.findViewById(R.id.screen_name);
mDescriptionView = (TextView) headerView.findViewById(R.id.description);
mLocationView = (TextView) headerView.findViewById(R.id.location);
mURLView = (TextView) headerView.findViewById(R.id.url);
mCreatedAtView = (TextView) headerView.findViewById(R.id.created_at);
mListedContainer = headerView.findViewById(R.id.listed_container);
mListedCount = (TextView) headerView.findViewById(R.id.listed_count);
mFollowersContainer = headerView.findViewById(R.id.followers_container);
mFollowersCount = (TextView) headerView.findViewById(R.id.followers_count);
mFriendsContainer = headerView.findViewById(R.id.friends_container);
mFriendsCount = (TextView) headerView.findViewById(R.id.friends_count);
mProfileNameContainer = (ColorLabelRelativeLayout) headerView.findViewById(R.id.profile_name_container);
mProfileImageView = (ShapedImageView) headerView.findViewById(R.id.profile_image);
mProfileTypeView = (ImageView) headerView.findViewById(R.id.profile_type);
mDescriptionContainer = headerView.findViewById(R.id.description_container);
mLocationContainer = headerView.findViewById(R.id.location_container);
mURLContainer = headerView.findViewById(R.id.url_container);
mProfileBannerSpace = headerView.findViewById(R.id.profile_banner_space);
mViewPager = (ViewPager) contentView.findViewById(R.id.view_pager);
mPagerIndicator = (TabPagerIndicator) contentView.findViewById(R.id.view_pager_tabs);
mFollowButton = (Button) headerView.findViewById(R.id.follow);
mFollowProgress = (ProgressBar) headerView.findViewById(R.id.follow_progress);
mUuckyFooter = headerView.findViewById(R.id.uucky_footer);
mPagesContent = view.findViewById(R.id.pages_content);
mPagesErrorContainer = view.findViewById(R.id.pages_error_container);
mPagesErrorIcon = (ImageView) view.findViewById(R.id.pages_error_icon);
mPagesErrorText = (TextView) view.findViewById(R.id.pages_error_text);
mProfileNameBackground = view.findViewById(R.id.profile_name_background);
mProfileDetailsContainer = view.findViewById(R.id.profile_details_container);
public boolean scrollToStart() {
if (!(mCurrentVisibleFragment instanceof RefreshScrollTopInterface)) return false;
((RefreshScrollTopInterface) mCurrentVisibleFragment).scrollToStart();
return true;
}
@Override
protected void fitSystemWindows(Rect insets) {
super.fitSystemWindows(insets);
mHeaderDrawerLayout.setPadding(insets.left, insets.top, insets.right, insets.bottom);
final FragmentActivity activity = getActivity();
final boolean isTransparentBackground;
if (activity instanceof IThemedActivity) {
final int themeRes = ((IThemedActivity) activity).getCurrentThemeResourceId();
isTransparentBackground = ThemeUtils.isTransparentBackground(themeRes);
} else {
isTransparentBackground = ThemeUtils.isTransparentBackground(getActivity());
}
mHeaderDrawerLayout.setClipToPadding(isTransparentBackground);
public boolean triggerRefresh() {
if (!(mCurrentVisibleFragment instanceof RefreshScrollTopInterface)) return false;
((RefreshScrollTopInterface) mCurrentVisibleFragment).triggerRefresh();
return true;
}
public void setListShown(boolean shown) {
@ -1211,43 +1212,11 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
return false;
}
private void updateFollowProgressState() {
final AsyncTwitterWrapper twitter = getTwitterWrapper();
final ParcelableUser user = getUser();
if (twitter == null || user == null) {
mFollowButton.setVisibility(View.GONE);
mFollowProgress.setVisibility(View.GONE);
return;
}
final LoaderManager lm = getLoaderManager();
final boolean loadingRelationship = lm.getLoader(LOADER_ID_FRIENDSHIP) != null;
final boolean creatingFriendship = twitter.isCreatingFriendship(user.account_id, user.id);
final boolean destroyingFriendship = twitter.isDestroyingFriendship(user.account_id, user.id);
final boolean creatingBlock = twitter.isCreatingFriendship(user.account_id, user.id);
final boolean destroyingBlock = twitter.isDestroyingFriendship(user.account_id, user.id);
if (loadingRelationship || creatingFriendship || destroyingFriendship || creatingBlock || destroyingBlock) {
mFollowButton.setVisibility(View.GONE);
mFollowProgress.setVisibility(View.VISIBLE);
} else if (mRelationship != null) {
mFollowButton.setVisibility(View.VISIBLE);
mFollowProgress.setVisibility(View.GONE);
} else {
mFollowButton.setVisibility(View.GONE);
mFollowProgress.setVisibility(View.GONE);
}
}
private void setupBaseActionBar() {
final FragmentActivity activity = getActivity();
if (!(activity instanceof LinkHandlerActivity)) return;
final LinkHandlerActivity linkHandler = (LinkHandlerActivity) activity;
final ActionBar actionBar = linkHandler.getSupportActionBar();
if (actionBar == null) return;
final Drawable shadow = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.shadow_user_banner_action_bar, null);
mActionBarBackground = new ActionBarDrawable(getResources(), shadow);
mActionBarBackground.setAlpha(linkHandler.getCurrentThemeBackgroundAlpha());
mProfileBannerView.setAlpha(linkHandler.getCurrentThemeBackgroundAlpha() / 255f);
actionBar.setBackgroundDrawable(mActionBarBackground);
private static void setCompatToolbarOverlayAlpha(FragmentActivity activity, float alpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return;
final Drawable drawable = ThemeUtils.getCompatToolbarOverlay(activity);
if (drawable == null) return;
drawable.setAlpha(Math.round(alpha * 255));
}
private void setUserUiColor(int color) {
@ -1281,6 +1250,19 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
}
}
private void setupBaseActionBar() {
final FragmentActivity activity = getActivity();
if (!(activity instanceof LinkHandlerActivity)) return;
final LinkHandlerActivity linkHandler = (LinkHandlerActivity) activity;
final ActionBar actionBar = linkHandler.getSupportActionBar();
if (actionBar == null) return;
final Drawable shadow = ResourcesCompat.getDrawable(activity.getResources(), R.drawable.shadow_user_banner_action_bar, null);
mActionBarBackground = new ActionBarDrawable(getResources(), shadow);
mActionBarBackground.setAlpha(linkHandler.getCurrentThemeBackgroundAlpha());
mProfileBannerView.setAlpha(linkHandler.getCurrentThemeBackgroundAlpha() / 255f);
actionBar.setBackgroundDrawable(mActionBarBackground);
}
private void setupUserPages() {
final Context context = getActivity();
final Bundle args = getArguments(), tabArgs = new Bundle();
@ -1307,7 +1289,43 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
return getActivity() instanceof LinkHandlerActivity;
}
private static final ArgbEvaluator sArgbEvaluator = new ArgbEvaluator();
private void updateFollowProgressState() {
final AsyncTwitterWrapper twitter = getTwitterWrapper();
final ParcelableUser user = getUser();
if (twitter == null || user == null) {
mFollowButton.setVisibility(View.GONE);
mFollowProgress.setVisibility(View.GONE);
return;
}
final LoaderManager lm = getLoaderManager();
final boolean loadingRelationship = lm.getLoader(LOADER_ID_FRIENDSHIP) != null;
final boolean creatingFriendship = twitter.isCreatingFriendship(user.account_id, user.id);
final boolean destroyingFriendship = twitter.isDestroyingFriendship(user.account_id, user.id);
final boolean creatingBlock = twitter.isCreatingFriendship(user.account_id, user.id);
final boolean destroyingBlock = twitter.isDestroyingFriendship(user.account_id, user.id);
if (loadingRelationship || creatingFriendship || destroyingFriendship || creatingBlock || destroyingBlock) {
mFollowButton.setVisibility(View.GONE);
mFollowProgress.setVisibility(View.VISIBLE);
} else if (mRelationship != null) {
mFollowButton.setVisibility(View.VISIBLE);
mFollowProgress.setVisibility(View.GONE);
} else {
mFollowButton.setVisibility(View.GONE);
mFollowProgress.setVisibility(View.GONE);
}
}
private void updateRefreshState() {
final ParcelableUser user = getUser();
if (user == null) return;
final AsyncTwitterWrapper twitter = getTwitterWrapper();
final boolean is_creating_friendship = twitter != null
&& twitter.isCreatingFriendship(user.account_id, user.id);
final boolean is_destroying_friendship = twitter != null
&& twitter.isDestroyingFriendship(user.account_id, user.id);
setProgressBarIndeterminateVisibility(is_creating_friendship || is_destroying_friendship);
invalidateOptionsMenu();
}
private void updateScrollOffset(int offset) {
final View space = mProfileBannerSpace;
@ -1366,13 +1384,6 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
updateTitleColor();
}
private static void setCompatToolbarOverlayAlpha(FragmentActivity activity, float alpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return;
final Drawable drawable = ThemeUtils.getCompatToolbarOverlay(activity);
if (drawable == null) return;
drawable.setAlpha(Math.round(alpha * 255));
}
private void updateTitleColor() {
final int[] location = new int[2];
mNameView.getLocationOnScreen(location);
@ -1397,6 +1408,71 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
activity.setTitle(spannedTitle);
}
private static class ActionBarDrawable extends LayerDrawable {
private final Drawable mShadowDrawable;
private final ColorDrawable mColorDrawable;
private float mFactor;
private int mColor;
private int mAlpha;
private float mOutlineAlphaFactor;
public ActionBarDrawable(Resources resources, Drawable shadow) {
super(new Drawable[]{shadow, new ActionBarColorDrawable(true)});
mShadowDrawable = getDrawable(0);
mColorDrawable = (ColorDrawable) getDrawable(1);
setAlpha(0xFF);
setOutlineAlphaFactor(1);
}
public int getColor() {
return mColor;
}
public void setColor(int color) {
mColor = color;
mColorDrawable.setColor(color);
setFactor(mFactor);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void getOutline(Outline outline) {
mColorDrawable.getOutline(outline);
outline.setAlpha(mFactor * mOutlineAlphaFactor * 0.99f);
}
@Override
public void setAlpha(int alpha) {
mAlpha = alpha;
setFactor(mFactor);
}
@Override
public int getIntrinsicWidth() {
return mColorDrawable.getIntrinsicWidth();
}
@Override
public int getIntrinsicHeight() {
return mColorDrawable.getIntrinsicHeight();
}
public void setFactor(float f) {
mFactor = f;
mShadowDrawable.setAlpha(Math.round(mAlpha * MathUtils.clamp(1 - f, 0, 1)));
final boolean hasColor = mColor != 0;
mColorDrawable.setAlpha(hasColor ? Math.round(mAlpha * MathUtils.clamp(f, 0, 1)) : 0);
}
public void setOutlineAlphaFactor(float f) {
mOutlineAlphaFactor = f;
invalidateSelf();
}
}
static class RelationshipLoader extends AsyncTaskLoader<SingleResponse<Relationship>> {
private final Context context;
@ -1434,70 +1510,4 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
}
}
private static class ActionBarDrawable extends LayerDrawable {
private final Drawable mShadowDrawable;
private final ColorDrawable mColorDrawable;
private float mFactor;
private int mColor;
private int mAlpha;
private float mOutlineAlphaFactor;
public ActionBarDrawable(Resources resources, Drawable shadow) {
super(new Drawable[]{shadow, new ActionBarColorDrawable(true)});
mShadowDrawable = getDrawable(0);
mColorDrawable = (ColorDrawable) getDrawable(1);
setAlpha(0xFF);
setOutlineAlphaFactor(1);
}
public int getColor() {
return mColor;
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void getOutline(Outline outline) {
mColorDrawable.getOutline(outline);
outline.setAlpha(mFactor * mOutlineAlphaFactor * 0.99f);
}
@Override
public void setAlpha(int alpha) {
mAlpha = alpha;
setFactor(mFactor);
}
public void setOutlineAlphaFactor(float f) {
mOutlineAlphaFactor = f;
invalidateSelf();
}
@Override
public int getIntrinsicWidth() {
return mColorDrawable.getIntrinsicWidth();
}
@Override
public int getIntrinsicHeight() {
return mColorDrawable.getIntrinsicHeight();
}
public void setColor(int color) {
mColor = color;
mColorDrawable.setColor(color);
setFactor(mFactor);
}
public void setFactor(float f) {
mFactor = f;
mShadowDrawable.setAlpha(Math.round(mAlpha * MathUtils.clamp(1 - f, 0, 1)));
final boolean hasColor = mColor != 0;
mColorDrawable.setAlpha(hasColor ? Math.round(mAlpha * MathUtils.clamp(f, 0, 1)) : 0);
}
}
}

View File

@ -32,7 +32,6 @@ import android.view.ViewGroup;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.util.TwidereLinkify;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.view.holder.StatusViewHolder;
import org.mariotaku.twidere.view.holder.StatusViewHolder.DummyStatusHolderAdapter;
@ -74,18 +73,16 @@ public class CardPreviewPreference extends Preference implements Constants, OnSh
if (KEY_COMPACT_CARDS.equals(key)) {
mCompactModeChanged = true;
}
mAdapter.updateOptions();
notifyChanged();
}
@Override
protected void onBindView(@NonNull final View view) {
if (mPreferences == null) return;
if (mHolder == null) return;
mCompactModeChanged = false;
final Context context = getContext();
final int highlightOption = Utils.getLinkHighlightingStyle(context);
mHolder = new StatusViewHolder(mAdapter, view);
mHolder.setupViewOptions();
mHolder.displaySampleStatus();
mLinkify.setHighlightOption(highlightOption);
super.onBindView(view);
}
@ -93,7 +90,9 @@ public class CardPreviewPreference extends Preference implements Constants, OnSh
protected View onCreateView(final ViewGroup parent) {
if (mPreferences != null && mPreferences.getBoolean(KEY_COMPACT_CARDS, false))
return mInflater.inflate(R.layout.card_item_status_compact, parent, false);
return mInflater.inflate(R.layout.card_item_status, parent, false);
final View view = mInflater.inflate(R.layout.card_item_status, parent, false);
mHolder = new StatusViewHolder(mAdapter, view);
return view;
}
}

View File

@ -37,6 +37,8 @@ import org.mariotaku.twidere.fragment.SettingsDetailsFragment;
*/
public class SwitchSettingsDetailsPreference extends SwitchPreference implements Constants {
private View mView;
public SwitchSettingsDetailsPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
final TypedArray a = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.src});
@ -68,6 +70,12 @@ public class SwitchSettingsDetailsPreference extends SwitchPreference implements
}
}
@Override
protected View onCreateView(ViewGroup parent) {
if (mView != null) return mView;
return mView = super.onCreateView(parent);
}
private static View findViewByType(View view, Class<? extends View> cls) {
if (cls.isAssignableFrom(view.getClass())) return view;
if (view instanceof ViewGroup) {

View File

@ -1,77 +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.util;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.text.Layout;
import android.text.SpannableString;
import android.text.style.LeadingMarginSpan.LeadingMarginSpan2;
import android.view.View;
import android.widget.TextView;
public class FlowTextHelper {
public static void flowText(final TextView textView, final View flowedView, final int additionalPadding) {
// Get height and width of the image and height of the text line
flowedView.measure(0, 0);
final int height = flowedView.getMeasuredHeight();
final int width = flowedView.getMeasuredWidth() + additionalPadding;
textView.measure(width, height); // to allow getTotalPaddingTop
final int padding = textView.getTotalPaddingTop();
final float textLineHeight = textView.getPaint().getTextSize();
// Set the span according to the number of lines and width of the image
final int lines = Math.round((height - padding) / textLineHeight);
final SpannableString ss = SpannableString.valueOf(textView.getText());
// For an html text you can use this line: SpannableStringBuilder ss =
// (SpannableStringBuilder)Html.fromHtml(text);
ss.setSpan(new FlowLeadingMarginSpan2(lines, width), 0, ss.length(), 0);
textView.setText(ss);
}
public static class FlowLeadingMarginSpan2 implements LeadingMarginSpan2 {
private final int margin;
private final int lines;
public FlowLeadingMarginSpan2(final int lines, final int margin) {
this.margin = margin;
this.lines = lines;
}
@Override
public void drawLeadingMargin(final Canvas c, final Paint p, final int x, final int dir, final int top,
final int baseline, final int bottom, final CharSequence text, final int start, final int end,
final boolean first, final Layout layout) {
}
@Override
public int getLeadingMargin(final boolean first) {
return first ? margin : 0;
}
@Override
public int getLeadingMarginLineCount() {
return lines;
}
}
}

View File

@ -73,6 +73,8 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
private final View quotedNameContainer;
private final IColorLabelView itemContent;
private final ForegroundColorView quoteIndicator;
private final View actionButtons;
private final View itemMenu;
private StatusClickListener statusClickListener;
@ -98,6 +100,9 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
quoteIndicator = (ForegroundColorView) itemView.findViewById(R.id.quote_indicator);
itemMenu = itemView.findViewById(R.id.item_menu);
actionButtons = itemView.findViewById(R.id.action_buttons);
replyCountView = (TextView) itemView.findViewById(R.id.reply_count);
retweetCountView = (TextView) itemView.findViewById(R.id.retweet_count);
favoriteCountView = (TextView) itemView.findViewById(R.id.favorite_count);
@ -106,11 +111,19 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
}
public void displaySampleStatus() {
profileImageView.setVisibility(adapter.isProfileImageEnabled() ? View.VISIBLE : View.GONE);
profileImageView.setImageResource(R.mipmap.ic_launcher);
nameView.setText(TWIDERE_PREVIEW_NAME);
screenNameView.setText("@" + TWIDERE_PREVIEW_SCREEN_NAME);
textView.setText(toPlainText(TWIDERE_PREVIEW_TEXT_HTML));
if (adapter.getLinkHighlightingStyle() == VALUE_LINK_HIGHLIGHT_OPTION_CODE_NONE) {
textView.setText(Html.fromHtml(TWIDERE_PREVIEW_TEXT_HTML));
adapter.getTwidereLinkify().applyAllLinks(textView, -1, -1, false, adapter.getLinkHighlightingStyle());
} else {
textView.setText(toPlainText(TWIDERE_PREVIEW_TEXT_HTML));
}
textView.setMovementMethod(null);
timeView.setTime(System.currentTimeMillis());
mediaPreview.setVisibility(adapter.isMediaPreviewEnabled() ? View.VISIBLE : View.GONE);
mediaPreview.displayMedia(R.drawable.nyan_stars_background);
}
@ -534,8 +547,8 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
public void setStatusClickListener(StatusClickListener listener) {
statusClickListener = listener;
itemView.findViewById(R.id.item_content).setOnClickListener(this);
itemView.findViewById(R.id.item_menu).setOnClickListener(this);
itemMenu.setOnClickListener(this);
itemView.setOnClickListener(this);
profileImageView.setOnClickListener(this);
replyCountView.setOnClickListener(this);
@ -561,6 +574,8 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
setTextSize(adapter.getTextSize());
mediaPreview.setStyle(adapter.getMediaPreviewStyle());
profileImageView.setStyle(adapter.getProfileImageStyle());
actionButtons.setVisibility(adapter.isCardActionsHidden() ? View.GONE : View.VISIBLE);
itemMenu.setVisibility(adapter.isCardActionsHidden() ? View.GONE : View.VISIBLE);
}
private void displayExtraTypeIcon(String cardName, ParcelableMedia[] media, ParcelableLocation location, String placeFullName, boolean sensitive) {
@ -599,43 +614,40 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
boolean isProfileImageEnabled();
void onStatusClick(StatusViewHolder holder, int position);
void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position);
void onStatusClick(StatusViewHolder holder, int position);
void onUserProfileClick(StatusViewHolder holder, int position);
}
public static final class DummyStatusHolderAdapter implements IStatusesAdapter<Object> {
private final Context context;
private final SharedPreferencesWrapper preferences;
private final MediaLoaderWrapper loader;
private final ImageLoadingHandler handler;
private final AsyncTwitterWrapper twitter;
private final TwidereLinkify linkify;
private final int profileImageStyle, mediaPreviewStyle;
private final boolean nameFirst;
private final boolean displayProfileImage;
private final boolean sensitiveContentEnabled;
private int profileImageStyle;
private int mediaPreviewStyle;
private int textSize;
private int linkHighlightStyle;
private boolean nameFirst;
private boolean displayProfileImage;
private boolean sensitiveContentEnabled;
private boolean hideCardActions;
private boolean displayMediaPreview;
public DummyStatusHolderAdapter(Context context) {
this.context = context;
final SharedPreferencesWrapper preferences = SharedPreferencesWrapper.getInstance(context,
SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
preferences = SharedPreferencesWrapper.getInstance(context, SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
final TwidereApplication app = TwidereApplication.getInstance(context);
loader = app.getMediaLoaderWrapper();
handler = new ImageLoadingHandler(R.id.media_preview_progress);
twitter = app.getTwitterWrapper();
linkify = new TwidereLinkify(null);
profileImageStyle = Utils.getProfileImageStyle(preferences.getString(KEY_PROFILE_IMAGE_STYLE, null));
mediaPreviewStyle = Utils.getMediaPreviewStyle(preferences.getString(KEY_MEDIA_PREVIEW_STYLE, null));
nameFirst = preferences.getBoolean(KEY_NAME_FIRST, true);
displayProfileImage = preferences.getBoolean(KEY_DISPLAY_PROFILE_IMAGE, true);
displayMediaPreview = preferences.getBoolean(KEY_MEDIA_PREVIEW, false);
sensitiveContentEnabled = preferences.getBoolean(KEY_DISPLAY_SENSITIVE_CONTENTS, false);
updateOptions();
}
@Override
@ -675,7 +687,7 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
@Override
public float getTextSize() {
return 0;
return textSize;
}
@Override
@ -688,46 +700,6 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
return false;
}
@Override
public boolean isProfileImageEnabled() {
return displayProfileImage;
}
@Override
public void onItemActionClick(ViewHolder holder, int id, int position) {
}
@Override
public void onItemMenuClick(ViewHolder holder, View menuView, int position) {
}
@Override
public void onStatusClick(StatusViewHolder holder, int position) {
}
@Override
public void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position) {
}
@Override
public void onUserProfileClick(StatusViewHolder holder, int position) {
}
@Override
public boolean isGapItem(int position) {
return false;
}
@Override
public void onGapClick(ViewHolder holder, int position) {
}
@Override
public void setLoadMoreSupported(boolean supported) {
@ -765,7 +737,7 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
@Override
public int getLinkHighlightingStyle() {
return 0;
return linkHighlightStyle;
}
@Override
@ -778,18 +750,75 @@ public class StatusViewHolder extends RecyclerView.ViewHolder implements Constan
return sensitiveContentEnabled;
}
@Override
public boolean isCardActionsHidden() {
return hideCardActions;
}
@Override
public void setData(Object o) {
}
@Override
public boolean shouldShowAccountsColor() {
return false;
}
public void setMediaPreviewEnabled(boolean enabled) {
displayMediaPreview = enabled;
}
@Override
public boolean shouldShowAccountsColor() {
public boolean isGapItem(int position) {
return false;
}
@Override
public void onGapClick(ViewHolder holder, int position) {
}
@Override
public boolean isProfileImageEnabled() {
return displayProfileImage;
}
@Override
public void onStatusClick(StatusViewHolder holder, int position) {
}
@Override
public void onMediaClick(StatusViewHolder holder, ParcelableMedia media, int position) {
}
@Override
public void onUserProfileClick(StatusViewHolder holder, int position) {
}
@Override
public void onItemActionClick(ViewHolder holder, int id, int position) {
}
@Override
public void onItemMenuClick(ViewHolder holder, View menuView, int position) {
}
public void updateOptions() {
profileImageStyle = Utils.getProfileImageStyle(preferences.getString(KEY_PROFILE_IMAGE_STYLE, null));
mediaPreviewStyle = Utils.getMediaPreviewStyle(preferences.getString(KEY_MEDIA_PREVIEW_STYLE, null));
textSize = preferences.getInt(KEY_TEXT_SIZE, context.getResources().getInteger(R.integer.default_text_size));
nameFirst = preferences.getBoolean(KEY_NAME_FIRST, true);
displayProfileImage = preferences.getBoolean(KEY_DISPLAY_PROFILE_IMAGE, true);
displayMediaPreview = preferences.getBoolean(KEY_MEDIA_PREVIEW, false);
sensitiveContentEnabled = preferences.getBoolean(KEY_DISPLAY_SENSITIVE_CONTENTS, false);
hideCardActions = preferences.getBoolean(KEY_HIDE_CARD_ACTIONS, false);
linkHighlightStyle = Utils.getLinkHighlightingStyleInt(preferences.getString(KEY_LINK_HIGHLIGHT_OPTION, null));
}
}
}

View File

@ -20,6 +20,7 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:baselineAligned="false"
@ -27,9 +28,7 @@
android:dividerPadding="@dimen/element_spacing_normal"
android:gravity="center_vertical"
android:orientation="horizontal"
android:showDividers="middle"
xmlns:app="http://schemas.android.com/apk/res-auto"
>
android:showDividers="middle">
<LinearLayout
android:layout_width="0dp"
@ -38,9 +37,9 @@
android:orientation="horizontal">
<RelativeLayout
android:id="@+id/account_selector_button"
style="?actionButtonStyle"
android:layout_width="wrap_content"
android:id="@+id/account_selector_button"
android:layout_height="match_parent"
android:clickable="true"
android:padding="@dimen/element_spacing_msmall">
@ -57,12 +56,12 @@
<org.mariotaku.twidere.view.BadgeView
android:id="@+id/accounts_count"
android:layout_alignTop="@id/account_profile_image"
android:layout_alignBottom="@id/account_profile_image"
android:layout_alignRight="@id/account_profile_image"
android:layout_alignLeft="@id/account_profile_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignBottom="@id/account_profile_image"
android:layout_alignLeft="@id/account_profile_image"
android:layout_alignRight="@id/account_profile_image"
android:layout_alignTop="@id/account_profile_image"
android:layout_gravity="center"
android:textColor="?android:colorForeground"/>

View File

@ -25,7 +25,7 @@
android:layout_height="match_parent"
android:layout_margin="@dimen/element_spacing_msmall">
<org.mariotaku.twidere.view.ShapedImageView
<org.mariotaku.twidere.view.SquareShapedImageView
android:id="@android:id/icon"
style="?profileImageStyle"
android:layout_width="match_parent"

View File

@ -60,7 +60,7 @@
android:layout_height="wrap_content"
android:padding="@dimen/element_spacing_small">
<org.mariotaku.twidere.view.ShapedImageView
<org.mariotaku.twidere.view.SquareShapedImageView
android:id="@+id/media_profile_image"
style="?profileImageStyle"
android:layout_width="@dimen/element_size_small"

View File

@ -58,7 +58,7 @@
android:gravity="center_vertical"
android:orientation="horizontal">
<org.mariotaku.twidere.view.ShapedImageView
<org.mariotaku.twidere.view.SquareShapedImageView
android:id="@+id/activity_profile_image_0"
style="?profileImageStyle"
android:layout_width="@dimen/profile_image_size_activity_small"
@ -66,7 +66,7 @@
android:layout_margin="2dp"
android:contentDescription="@string/profile_image"/>
<org.mariotaku.twidere.view.ShapedImageView
<org.mariotaku.twidere.view.SquareShapedImageView
android:id="@+id/activity_profile_image_1"
style="?profileImageStyle"
android:layout_width="@dimen/profile_image_size_activity_small"
@ -74,7 +74,7 @@
android:layout_margin="2dp"
android:contentDescription="@string/profile_image"/>
<org.mariotaku.twidere.view.ShapedImageView
<org.mariotaku.twidere.view.SquareShapedImageView
android:id="@+id/activity_profile_image_2"
style="?profileImageStyle"
android:layout_width="@dimen/profile_image_size_activity_small"
@ -82,7 +82,7 @@
android:layout_margin="2dp"
android:contentDescription="@string/profile_image"/>
<org.mariotaku.twidere.view.ShapedImageView
<org.mariotaku.twidere.view.SquareShapedImageView
android:id="@+id/activity_profile_image_3"
style="?profileImageStyle"
android:layout_width="@dimen/profile_image_size_activity_small"
@ -90,7 +90,7 @@
android:layout_margin="2dp"
android:contentDescription="@string/profile_image"/>
<org.mariotaku.twidere.view.ShapedImageView
<org.mariotaku.twidere.view.SquareShapedImageView
android:id="@+id/activity_profile_image_4"
style="?profileImageStyle"
android:layout_width="@dimen/profile_image_size_activity_small"

View File

@ -108,7 +108,7 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/element_spacing_normal"
android:layout_toLeftOf="@+id/item_menu"
android:layout_toLeftOf="@+id/extra_type"
android:layout_toRightOf="@id/profile_image"
android:orientation="vertical">
@ -148,7 +148,6 @@
android:id="@+id/time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical"
android:paddingBottom="@dimen/element_spacing_small"
android:paddingTop="@dimen/element_spacing_xsmall"
@ -159,15 +158,18 @@
</LinearLayout>
<org.mariotaku.twidere.view.ActionIconButton
android:id="@+id/item_menu"
style="?cardActionButtonStyle"
android:layout_width="@dimen/element_size_normal"
android:layout_height="@dimen/element_size_normal"
<org.mariotaku.twidere.view.ActionIconView
android:id="@+id/extra_type"
android:layout_width="@dimen/element_size_small"
android:layout_height="@dimen/element_size_small"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:focusable="false"
android:src="@drawable/ic_action_more_vertical"/>
android:layout_marginBottom="@dimen/element_spacing_normal"
android:layout_marginLeft="@dimen/element_spacing_mlarge"
android:layout_marginRight="@dimen/element_spacing_mlarge"
android:layout_marginTop="@dimen/element_spacing_normal"
android:color="?android:textColorSecondary"
tools:src="@drawable/ic_action_gallery"/>
</RelativeLayout>
@ -252,7 +254,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/media_preview"
android:layout_marginBottom="@dimen/element_spacing_small"
android:layout_marginBottom="@dimen/element_spacing_normal"
android:layout_marginTop="@dimen/element_spacing_normal"
android:layout_toRightOf="@+id/quote_indicator"
android:paddingLeft="@dimen/element_spacing_normal"
@ -261,13 +263,13 @@
android:textColor="?android:attr/textColorPrimary"
tools:text="@string/sample_status_text"/>
<LinearLayout
android:id="@+id/action_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/profile_container"
android:layout_below="@+id/text"
android:layout_marginTop="@dimen/element_spacing_minus_small"
android:gravity="center_vertical|left"
android:orientation="horizontal">
@ -315,19 +317,20 @@
</LinearLayout>
<org.mariotaku.twidere.view.ActionIconView
android:id="@+id/extra_type"
android:layout_width="@dimen/element_size_small"
android:layout_height="@dimen/element_size_small"
<org.mariotaku.twidere.view.ActionIconButton
android:id="@+id/item_menu"
style="?cardActionButtonStyle"
android:layout_width="@dimen/element_size_normal"
android:layout_height="@dimen/element_size_normal"
android:layout_alignBottom="@+id/action_buttons"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/action_buttons"
android:layout_below="@+id/text"
android:layout_gravity="center|right"
android:layout_marginBottom="@dimen/element_spacing_small"
android:layout_marginLeft="@dimen/element_spacing_normal"
android:layout_marginRight="@dimen/element_spacing_normal"
android:layout_weight="0"
android:color="?android:textColorSecondary"
tools:src="@drawable/ic_action_gallery"/>
android:color="?android:textColorTertiary"
android:focusable="false"
android:src="@drawable/ic_action_more_vertical"/>
</org.mariotaku.twidere.view.ColorLabelRelativeLayout>
</merge>

View File

@ -238,6 +238,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/media_preview"
android:layout_marginBottom="@dimen/element_spacing_small"
android:layout_marginTop="@dimen/element_spacing_small"
android:layout_toRightOf="@+id/quote_indicator"
android:textAppearance="?android:attr/textAppearanceSmall"
@ -253,6 +254,7 @@
android:layout_height="wrap_content"
android:layout_alignLeft="@id/status_content"
android:layout_below="@+id/status_content"
android:layout_marginTop="@dimen/element_spacing_minus_small"
android:layout_toLeftOf="@+id/item_menu"
android:gravity="center_vertical"
android:orientation="horizontal">
@ -312,6 +314,9 @@
android:layout_height="@dimen/button_size_content_card"
android:layout_alignBottom="@+id/action_buttons"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/action_buttons"
android:layout_marginTop="@dimen/element_spacing_minus_small"
android:color="?android:textColorTertiary"
android:focusable="false"
android:src="@drawable/ic_action_more_horizontal"/>

View File

@ -38,7 +38,7 @@
android:orientation="horizontal"
android:padding="@dimen/element_spacing_small">
<org.mariotaku.twidere.view.ShapedImageView
<org.mariotaku.twidere.view.SquareShapedImageView
android:id="@+id/profile_image"
style="?profileImageStyle"
android:layout_width="@dimen/icon_size_list_item_small"

View File

@ -35,7 +35,7 @@
app:ignorePadding="true"
tools:context=".adapter.DirectMessagesEntryAdapter">
<org.mariotaku.twidere.view.ShapedImageView
<org.mariotaku.twidere.view.SquareShapedImageView
android:id="@+id/profile_image"
style="?profileImageStyle"
android:layout_width="@dimen/icon_size_card_list_item"

View File

@ -28,7 +28,7 @@
android:orientation="horizontal"
android:padding="@dimen/element_spacing_normal">
<org.mariotaku.twidere.view.ShapedImageView
<org.mariotaku.twidere.view.SquareShapedImageView
android:id="@android:id/icon"
style="?profileImageStyle"
android:layout_width="@dimen/icon_size_list_item_small"

View File

@ -57,7 +57,7 @@
tools:text="Created by Mariotaku"/>
</LinearLayout>
<org.mariotaku.twidere.view.ShapedImageView
<org.mariotaku.twidere.view.SquareShapedImageView
android:id="@+id/profile_image"
style="?profileImageStyle"
android:layout_width="@dimen/icon_size_card_list_item"

View File

@ -18,7 +18,7 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<org.mariotaku.twidere.view.ShapedImageView
<org.mariotaku.twidere.view.SquareShapedImageView
android:id="@+id/color"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"

View File

@ -26,7 +26,7 @@
android:padding="@dimen/element_spacing_small"
tools:layout_height="?android:actionBarSize">
<org.mariotaku.twidere.view.ShapedImageView
<org.mariotaku.twidere.view.SquareShapedImageView
android:id="@android:id/icon"
style="?profileImageStyle"
android:layout_width="match_parent"

View File

@ -744,6 +744,7 @@
<string name="thumbor_integration">Thumbor integration</string>
<string name="server_address">Server address</string>
<string name="security_key">Security key</string>
<string name="hide_card_actions">Hide card actions</string>
</resources>

View File

@ -25,6 +25,21 @@
android:key="media_preview"
android:order="24"
android:title="@string/media_preview"/>
<org.mariotaku.twidere.preference.SummaryListPreference
android:defaultValue="@string/default_profile_image_style"
android:entries="@array/entries_profile_image_style"
android:entryValues="@array/values_profile_image_style"
android:key="profile_image_style"
android:order="25"
android:title="@string/profile_image_style"/>
<org.mariotaku.twidere.preference.SummaryListPreference
android:defaultValue="crop"
android:entries="@array/entries_media_preview_style"
android:entryValues="@array/values_media_preview_style"
android:key="media_preview_style"
android:order="26"
android:title="@string/media_preview_style"/>
<org.mariotaku.twidere.preference.LinkHighlightPreference
android:defaultValue="none"
@ -63,5 +78,10 @@
android:order="32"
android:summary="@string/compact_cards_summary"
android:title="@string/compact_cards"/>
<org.mariotaku.twidere.preference.AutoFixCheckBoxPreference
android:defaultValue="false"
android:key="hide_card_actions"
android:order="33"
android:title="@string/hide_card_actions"/>
</PreferenceScreen>

View File

@ -45,18 +45,5 @@
android:key="tab_display_option"
android:title="@string/tab_display_option"/>
<org.mariotaku.twidere.preference.SummaryListPreference
android:defaultValue="@string/default_profile_image_style"
android:entries="@array/entries_profile_image_style"
android:entryValues="@array/values_profile_image_style"
android:key="profile_image_style"
android:title="@string/profile_image_style"/>
<org.mariotaku.twidere.preference.SummaryListPreference
android:defaultValue="crop"
android:entries="@array/entries_media_preview_style"
android:entryValues="@array/values_media_preview_style"
android:key="media_preview_style"
android:title="@string/media_preview_style"/>
</PreferenceScreen>

View File

@ -65,11 +65,28 @@
android:summary="@string/default_api_settings_summary"
android:title="@string/default_api_settings"/>
<org.mariotaku.twidere.preference.SwitchSettingsDetailsPreference
</PreferenceCategory>
<PreferenceCategory
android:key="category_api"
android:title="@string/thumbor_integration">
<SwitchPreference
android:defaultValue="false"
android:key="thumbor_enabled"
android:src="@xml/preferences_thumbor"
android:title="@string/thumbor_integration"/>
<org.mariotaku.twidere.preference.AutoFixEditTextPreference
android:dependency="thumbor_enabled"
android:inputType="textUri"
android:key="thumbor_address"
android:title="@string/server_address"/>
<org.mariotaku.twidere.preference.AutoFixEditTextPreference
android:dependency="thumbor_enabled"
android:inputType="textVisiblePassword"
android:key="thumbor_security_key"
android:title="@string/security_key"/>
</PreferenceCategory>
</PreferenceScreen>