improved user profile tab appearance & action bar below lollipop

improved user lists tab appearance
improved search appearance
message entry will not show unread when first message is outgoing
This commit is contained in:
Mariotaku Lee 2015-04-03 23:49:08 +08:00
parent 5eb10fb836
commit d952629ac2
25 changed files with 449 additions and 138 deletions

View File

@ -229,7 +229,8 @@ public class LinkHandlerActivity extends BaseActionBarActivity implements OnClic
case LINK_ID_USER: {
break;
}
case LINK_ID_SEARCH: {
case LINK_ID_SEARCH:
case LINK_ID_USER_LISTS: {
ThemeUtils.applyActionBarBackground(actionBar, this, getCurrentThemeResourceId(),
getCurrentThemeColor(), false);
break;

View File

@ -36,7 +36,7 @@ public abstract class SupportFixedFragmentStatePagerAdapter extends FragmentStat
public Object instantiateItem(final ViewGroup container, final int position) {
final Fragment f = (Fragment) super.instantiateItem(container, position);
final Bundle savedFragmentState = f != null ? FragmentTrojan.getSavedFragmentState(f) : null;
if (savedFragmentState != null && f != null) {
if (savedFragmentState != null) {
savedFragmentState.setClassLoader(f.getClass().getClassLoader());
}
return f;

View File

@ -24,7 +24,9 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import org.mariotaku.twidere.Constants;
import org.mariotaku.twidere.fragment.iface.RefreshScrollTopInterface;
@ -43,7 +45,7 @@ import static org.mariotaku.twidere.util.Utils.announceForAccessibilityCompat;
public class SupportTabsAdapter extends SupportFixedFragmentStatePagerAdapter implements TabProvider, TabListener,
Constants {
private final ArrayList<SupportTabSpec> mTabs = new ArrayList<SupportTabSpec>();
private final ArrayList<SupportTabSpec> mTabs = new ArrayList<>();
private final Context mContext;
private final PagerIndicator mIndicator;
@ -95,10 +97,18 @@ public class SupportTabsAdapter extends SupportFixedFragmentStatePagerAdapter im
@Override
public Fragment getItem(final int position) {
final Fragment fragment = Fragment.instantiate(mContext, mTabs.get(position).cls.getName());
fragment.setArguments(mTabs.get(position).args);
fragment.setArguments(getPageArguments(mTabs.get(position).args, position));
return fragment;
}
private Bundle getPageArguments(Bundle args, int position) {
if (args == null) {
args = new Bundle();
}
args.putInt(EXTRA_TAB_POSITION, position);
return args;
}
@Override
public Drawable getPageIcon(final int position) {
return getTabIconDrawable(mContext, mTabs.get(position).icon);
@ -135,8 +145,22 @@ public class SupportTabsAdapter extends SupportFixedFragmentStatePagerAdapter im
}
}
@Override
public void startUpdate(ViewGroup container) {
super.startUpdate(container);
}
@Override
public int getItemPosition(Object object) {
if (!(object instanceof Fragment)) return POSITION_NONE;
final Bundle args = ((Fragment) object).getArguments();
if (args == null) return POSITION_NONE;
return args.getInt(EXTRA_TAB_POSITION, POSITION_NONE);
}
@Override
public void onPageSelected(final int position) {
Log.d(LOGTAG, "onPageSelected " + position);
if (mIndicator == null) return;
announceForAccessibilityCompat(mContext, (View) mIndicator, getPageTitle(position), getClass());
}

View File

@ -29,7 +29,6 @@ import android.os.Bundle;
import android.provider.SearchRecentSuggestions;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.LayoutInflater;
@ -42,7 +41,6 @@ import android.view.ViewGroup;
import org.mariotaku.twidere.R;
import org.mariotaku.twidere.activity.iface.IControlBarActivity;
import org.mariotaku.twidere.activity.iface.IControlBarActivity.ControlBarOffsetListener;
import org.mariotaku.twidere.activity.iface.IThemedActivity;
import org.mariotaku.twidere.activity.support.ComposeActivity;
import org.mariotaku.twidere.activity.support.LinkHandlerActivity;
import org.mariotaku.twidere.adapter.support.SupportTabsAdapter;
@ -52,7 +50,6 @@ import org.mariotaku.twidere.fragment.iface.SupportFragmentCallback;
import org.mariotaku.twidere.provider.RecentSearchProvider;
import org.mariotaku.twidere.provider.TwidereDataStore.SearchHistory;
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
import org.mariotaku.twidere.util.ColorUtils;
import org.mariotaku.twidere.util.ThemeUtils;
import org.mariotaku.twidere.util.Utils;
import org.mariotaku.twidere.view.TabPagerIndicator;
@ -166,18 +163,7 @@ public class SearchFragment extends BaseSupportFragment implements RefreshScroll
mPagerIndicator.setViewPager(mViewPager);
mPagerIndicator.setTabDisplayOption(TabPagerIndicator.LABEL);
mPagerIndicator.setOnPageChangeListener(this);
if (activity instanceof IThemedActivity) {
final int themeColor = ((IThemedActivity) activity).getCurrentThemeColor();
final int contrastColor = ColorUtils.getContrastYIQ(themeColor, 192);
mPagerIndicator.setBackgroundColor(themeColor);
mPagerIndicator.setIconColor(contrastColor);
mPagerIndicator.setLabelColor(contrastColor);
mPagerIndicator.setStripColor(contrastColor);
} else {
mPagerIndicator.setBackgroundColor(ThemeUtils.getThemeColor(activity));
}
final float supportActionBarElevation = ThemeUtils.getSupportActionBarElevation(activity);
ViewCompat.setElevation(mPagerIndicator, supportActionBarElevation);
ThemeUtils.initPagerIndicatorAsActionBarTab(activity,mPagerIndicator);
if (savedInstanceState == null && args != null && args.containsKey(EXTRA_QUERY)) {
final String query = args.getString(EXTRA_QUERY);
final SearchRecentSuggestions suggestions = new SearchRecentSuggestions(getActivity(),

View File

@ -19,6 +19,7 @@
package org.mariotaku.twidere.fragment.support;
import android.animation.ArgbEvaluator;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.ActivityNotFoundException;
@ -60,7 +61,7 @@ import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.view.ViewCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.CardView;
import android.support.v7.internal.widget.ActionBarOverlayLayout;
import android.text.Html;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
@ -132,6 +133,7 @@ import org.mariotaku.twidere.view.TabPagerIndicator;
import org.mariotaku.twidere.view.TintedStatusFrameLayout;
import org.mariotaku.twidere.view.iface.IExtendedView.OnSizeChangedListener;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Locale;
@ -195,7 +197,6 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
private HeaderDrawerLayout mHeaderDrawerLayout;
private ViewPager mViewPager;
private TabPagerIndicator mPagerIndicator;
private CardView mCardView;
private View mUuckyFooter;
private View mProfileBannerContainer;
private Button mFollowButton;
@ -216,6 +217,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
private int mBannerWidth;
private ActionBarDrawable mActionBarBackground;
private Fragment mCurrentVisibleFragment;
private int mCardBackgroundColor;
@Subscribe
@ -529,7 +531,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
@Override
public boolean shouldLayoutHeaderBottom() {
final HeaderDrawerLayout drawer = mHeaderDrawerLayout;
final CardView card = mCardView;
final View card = mProfileDetailsContainer;
if (drawer == null || card == null) return false;
return card.getTop() + drawer.getHeaderTop() - drawer.getPaddingTop() <= 0;
}
@ -628,13 +630,13 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_user, container, false);
final ViewGroup profileDetailsContainer = (ViewGroup) view.findViewById(R.id.profile_details_container);
final boolean isCompact = Utils.isCompactCards(getActivity());
if (isCompact) {
inflater.inflate(R.layout.layout_user_details_compact, profileDetailsContainer);
} else {
inflater.inflate(R.layout.layout_user_details, profileDetailsContainer);
}
// final ViewGroup profileDetailsContainer = (ViewGroup) view.findViewById(R.id.profile_details_container);
// final boolean isCompact = Utils.isCompactCards(getActivity());
// if (isCompact) {
// inflater.inflate(R.layout.layout_user_details_compact, profileDetailsContainer);
// } else {
// inflater.inflate(R.layout.layout_user_details, profileDetailsContainer);
// }
return view;
}
@ -642,12 +644,15 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
@Override
public void onActivityCreated(final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final FragmentActivity activity = getActivity();
setHasOptionsMenu(true);
getSharedPreferences(USER_COLOR_PREFERENCES_NAME, Context.MODE_PRIVATE)
.registerOnSharedPreferenceChangeListener(this);
getSharedPreferences(USER_NICKNAME_PREFERENCES_NAME, Context.MODE_PRIVATE)
.registerOnSharedPreferenceChangeListener(this);
mLocale = getResources().getConfiguration().locale;
mCardBackgroundColor = ThemeUtils.getCardBackgroundColor(activity);
mProfileImageLoader = getApplication().getMediaLoaderWrapper();
final Bundle args = getArguments();
long accountId = -1, userId = -1;
String screenName = null;
@ -658,8 +663,6 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
userId = args.getLong(EXTRA_USER_ID, -1);
screenName = args.getString(EXTRA_SCREEN_NAME);
}
mProfileImageLoader = getApplication().getMediaLoaderWrapper();
final FragmentActivity activity = getActivity();
Utils.setNdefPushMessageCallback(activity, new CreateNdefMessageCallback() {
@ -707,7 +710,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
ViewCompat.setTransitionName(mProfileImageView, TRANSITION_NAME_PROFILE_IMAGE);
ViewCompat.setTransitionName(mProfileTypeView, TRANSITION_NAME_PROFILE_TYPE);
ViewCompat.setTransitionName(mCardView, TRANSITION_NAME_CARD);
// ViewCompat.setTransitionName(mCardView, TRANSITION_NAME_CARD);
mHeaderDrawerLayout.setDrawerCallback(this);
@ -729,7 +732,9 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
mProfileBannerSpace.setOnTouchListener(this);
mCardView.setCardBackgroundColor(ThemeUtils.getCardBackgroundColor(activity));
mProfileNameBackground.setBackgroundColor(mCardBackgroundColor);
mProfileDetailsContainer.setBackgroundColor(mCardBackgroundColor);
mUuckyFooter.setBackgroundColor(mCardBackgroundColor);
getUserInfo(accountId, userId, screenName, false);
@ -1129,7 +1134,7 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
mErrorMessageView = (TextView) headerView.findViewById(R.id.error_message);
mProfileBannerView = (ProfileBannerImageView) view.findViewById(R.id.profile_banner);
mProfileBannerContainer = view.findViewById(R.id.profile_banner_container);
mCardView = (CardView) headerView.findViewById(R.id.card);
// mCardView = (CardView) headerView.findViewById(R.id.card);
mNameView = (TextView) headerView.findViewById(R.id.name);
mScreenNameView = (TextView) headerView.findViewById(R.id.screen_name);
mDescriptionView = (TextView) headerView.findViewById(R.id.description);
@ -1272,15 +1277,16 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
mURLView.setLinkTextColor(color);
if (activity instanceof IThemedActivity) {
final int themeRes = ((IThemedActivity) activity).getCurrentThemeResourceId();
if (ThemeUtils.isDarkTheme(themeRes)) {
ViewAccessor.setBackground(mPagerIndicator, ThemeUtils.getActionBarBackground(activity, themeRes));
mPagerIndicator.setStripColor(color);
} else {
mPagerIndicator.setBackgroundColor(color);
}
ViewAccessor.setBackground(mPagerIndicator, ThemeUtils.getActionBarStackedBackground(activity, themeRes, color, true));
} else {
mPagerIndicator.setBackgroundColor(color);
}
final HeaderDrawerLayout drawer = mHeaderDrawerLayout;
if (drawer != null) {
final int offset = drawer.getPaddingTop() - drawer.getHeaderTop();
updateScrollOffset(offset);
}
}
private void setupUserPages() {
@ -1309,6 +1315,8 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
return getActivity() instanceof LinkHandlerActivity;
}
private static final ArgbEvaluator sArgbEvaluator = new ArgbEvaluator();
private void updateScrollOffset(int offset) {
final View space = mProfileBannerSpace;
final ProfileBannerImageView profileBannerView = mProfileBannerView;
@ -1323,26 +1331,65 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
mTintedStatusContent.setFactor(factor);
final float profileContentHeight = mProfileNameContainer.getHeight() + mProfileDetailsContainer.getHeight();
final float outlineAlphaFactor;
final float tabOutlineAlphaFactor;
if ((offset - spaceHeight) > 0) {
outlineAlphaFactor = 1f - MathUtils.clamp((offset - spaceHeight) / profileContentHeight, 0, 1);
tabOutlineAlphaFactor = 1f - MathUtils.clamp((offset - spaceHeight) / profileContentHeight, 0, 1);
} else {
outlineAlphaFactor = 1f;
tabOutlineAlphaFactor = 1f;
}
mActionBarBackground.setOutlineAlphaFactor(outlineAlphaFactor);
final Drawable drawable = mPagerIndicator.getBackground();
if (drawable != null) {
drawable.setAlpha(Math.round(255 * (1 - outlineAlphaFactor)));
mActionBarBackground.setOutlineAlphaFactor(tabOutlineAlphaFactor);
final FragmentActivity activity = getActivity();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
setCompatToolbarOverlayAlpha(activity, factor * tabOutlineAlphaFactor);
}
final int color = mActionBarBackground.getColor();
final int contrastColor = ColorUtils.getContrastYIQ(color, 192);
mPagerIndicator.setIconColor(contrastColor);
mPagerIndicator.setLabelColor(contrastColor);
mPagerIndicator.setStripColor(contrastColor);
if (activity instanceof IThemedActivity) {
final Drawable drawable = mPagerIndicator.getBackground();
final int stackedTabColor;
if (ThemeUtils.isDarkTheme(((IThemedActivity) activity).getCurrentThemeResourceId())) {
stackedTabColor = getResources().getColor(R.color.background_color_action_bar_dark);
final int contrastColor = ColorUtils.getContrastYIQ(stackedTabColor, 192);
mPagerIndicator.setIconColor(contrastColor);
mPagerIndicator.setLabelColor(contrastColor);
mPagerIndicator.setStripColor(color);
} else if (drawable instanceof ColorDrawable) {
stackedTabColor = color;
final int tabColor = (Integer) sArgbEvaluator.evaluate(tabOutlineAlphaFactor, stackedTabColor, mCardBackgroundColor);
((ColorDrawable) drawable).setColor(tabColor);
final int contrastColor = ColorUtils.getContrastYIQ(tabColor, 192);
mPagerIndicator.setIconColor(contrastColor);
mPagerIndicator.setLabelColor(contrastColor);
mPagerIndicator.setStripColor(contrastColor);
}
} else {
final int contrastColor = ColorUtils.getContrastYIQ(color, 192);
mPagerIndicator.setIconColor(contrastColor);
mPagerIndicator.setLabelColor(contrastColor);
mPagerIndicator.setStripColor(contrastColor);
}
mPagerIndicator.updateAppearance();
}
updateTitleColor();
}
private void setCompatToolbarOverlayAlpha(FragmentActivity activity, float alpha) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return;
final View view = activity.getWindow().findViewById(android.support.v7.appcompat.R.id.decor_content_parent);
if (!(view instanceof ActionBarOverlayLayout)) return;
try {
final Field field = ActionBarOverlayLayout.class.getDeclaredField("mWindowContentOverlay");
field.setAccessible(true);
final Drawable drawable = (Drawable) field.get(view);
if (drawable == null) return;
drawable.setAlpha(Math.round(alpha * 255));
} catch (Exception ignore) {
}
}
private void updateTitleColor() {
final int[] location = new int[2];
mNameView.getLocationOnScreen(location);
@ -1408,7 +1455,6 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
private final Drawable mShadowDrawable;
private final Drawable mBackgroundDrawable;
// private final LineBackgroundDrawable mLineDrawable;
private final ColorDrawable mColorDrawable;
private final boolean mColorLineOnly;
@ -1422,7 +1468,6 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
super(new Drawable[]{shadow, background, new ActionBarColorDrawable(true)});
mShadowDrawable = getDrawable(0);
mBackgroundDrawable = getDrawable(1);
// mLineDrawable = (LineBackgroundDrawable) getDrawable(2);
mColorDrawable = (ColorDrawable) getDrawable(2);
mColorLineOnly = colorLineOnly;
setAlpha(0xFF);
@ -1479,7 +1524,6 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
public void setColor(int color) {
mColor = color;
mColorDrawable.setColor(color);
// mLineDrawable.setColor(color);
setFactor(mFactor);
}
@ -1491,7 +1535,6 @@ public class UserFragment extends BaseSupportFragment implements OnClickListener
final boolean showLine = mColorLineOnly && hasColor;
final boolean showColor = !mColorLineOnly && hasColor;
mBackgroundDrawable.setAlpha(showBackground ? Math.round(mAlpha * MathUtils.clamp(f, 0, 1)) : 0);
// mLineDrawable.setAlpha(showLine ? Math.round(mAlpha * MathUtils.clamp(f, 0, 1)) : 0);
mColorDrawable.setAlpha(showColor ? Math.round(mAlpha * MathUtils.clamp(f, 0, 1)) : 0);
}

View File

@ -34,6 +34,7 @@ import org.mariotaku.twidere.adapter.support.SupportTabsAdapter;
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.util.ThemeUtils;
import org.mariotaku.twidere.view.TabPagerIndicator;
public class UserListsFragment extends BaseSupportFragment implements RefreshScrollTopInterface,
@ -66,9 +67,7 @@ public class UserListsFragment extends BaseSupportFragment implements RefreshScr
mViewPager.setOffscreenPageLimit(2);
mPagerIndicator.setViewPager(mViewPager);
mPagerIndicator.setTabDisplayOption(TabPagerIndicator.LABEL);
if (activity instanceof IThemedActivity) {
mPagerIndicator.setStripColor(((IThemedActivity) activity).getCurrentThemeColor());
}
ThemeUtils.initPagerIndicatorAsActionBarTab(activity, mPagerIndicator);
}

View File

@ -35,6 +35,8 @@ import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewCompat;
import android.support.v7.internal.view.menu.ActionMenuItemView;
import android.support.v7.widget.ActionMenuView;
import android.text.SpannableStringBuilder;
@ -61,6 +63,7 @@ import org.mariotaku.twidere.graphic.ActionIconDrawable;
import org.mariotaku.twidere.text.ParagraphSpacingSpan;
import org.mariotaku.twidere.util.accessor.ViewAccessor;
import org.mariotaku.twidere.util.menu.TwidereMenuInfo;
import org.mariotaku.twidere.view.TabPagerIndicator;
import org.mariotaku.twidere.view.iface.IThemedView;
import java.lang.reflect.Constructor;
@ -79,25 +82,12 @@ public class ThemeUtils implements Constants {
throw new AssertionError();
}
@Deprecated
public static void applyActionBarBackground(final ActionBar actionBar, final Context context) {
applyActionBarBackground(actionBar, context, true);
}
@Deprecated
public static void applyActionBarBackground(final ActionBar actionBar, final Context context,
final boolean applyAlpha) {
if (actionBar == null || context == null) return;
actionBar.setBackgroundDrawable(getActionBarBackground(context, applyAlpha));
actionBar.setSplitBackgroundDrawable(getActionBarSplitBackground(context, applyAlpha));
actionBar.setStackedBackgroundDrawable(getActionBarStackedBackground(context, applyAlpha));
}
public static void applyActionBarBackground(final ActionBar actionBar, final Context context, final int themeRes) {
if (actionBar == null || context == null) return;
actionBar.setBackgroundDrawable(getActionBarBackground(context, themeRes));
actionBar.setSplitBackgroundDrawable(getActionBarSplitBackground(context, themeRes));
actionBar.setStackedBackgroundDrawable(getActionBarStackedBackground(context, themeRes));
// actionBar.setStackedBackgroundDrawable(getActionBarStackedBackground(context, themeRes));
}
@ -106,7 +96,7 @@ public class ThemeUtils implements Constants {
if (actionBar == null || context == null) return;
actionBar.setBackgroundDrawable(getActionBarBackground(context, themeRes, accentColor, outlineEnabled));
actionBar.setSplitBackgroundDrawable(getActionBarSplitBackground(context, themeRes));
actionBar.setStackedBackgroundDrawable(getActionBarStackedBackground(context, themeRes));
actionBar.setStackedBackgroundDrawable(getActionBarBackground(context, themeRes, accentColor, outlineEnabled));
}
@ -115,7 +105,7 @@ public class ThemeUtils implements Constants {
if (actionBar == null || context == null) return;
actionBar.setBackgroundDrawable(getActionBarBackground(context, themeRes, accentColor, outlineEnabled));
actionBar.setSplitBackgroundDrawable(getActionBarSplitBackground(context, themeRes));
actionBar.setStackedBackgroundDrawable(getActionBarStackedBackground(context, themeRes));
actionBar.setStackedBackgroundDrawable(getActionBarStackedBackground(context, themeRes, accentColor, outlineEnabled));
}
@ -138,6 +128,27 @@ public class ThemeUtils implements Constants {
}
}
public static void initPagerIndicatorAsActionBarTab(FragmentActivity activity, TabPagerIndicator indicator) {
final float supportActionBarElevation = getSupportActionBarElevation(activity);
ViewCompat.setElevation(indicator, supportActionBarElevation);
if (!(activity instanceof IThemedActivity)) return;
final int themeRes = ((IThemedActivity) activity).getCurrentThemeResourceId();
final int themeColor = ((IThemedActivity) activity).getCurrentThemeColor();
final int contrastColor = ColorUtils.getContrastYIQ(themeColor, 192);
ViewAccessor.setBackground(indicator, getActionBarStackedBackground(activity, themeRes, themeColor, true));
if (isDarkTheme(themeRes)) {
final int foregroundColor = getThemeForegroundColor(activity);
indicator.setIconColor(foregroundColor);
indicator.setLabelColor(foregroundColor);
indicator.setStripColor(themeColor);
} else {
indicator.setIconColor(contrastColor);
indicator.setLabelColor(contrastColor);
indicator.setStripColor(contrastColor);
}
indicator.updateAppearance();
}
public static void resetCheatSheet(ActionMenuView menuView) {
final OnLongClickListener listener = new OnLongClickListener() {
@Override
@ -406,16 +417,29 @@ public class ThemeUtils implements Constants {
return null;
}
@NonNull
public static Drawable getActionBarBackground(final Context context, final int themeRes,
final int accentColor, boolean outlineEnabled) {
if (!isDarkTheme(themeRes)) {
final ColorDrawable d = new ActionBarColorDrawable(accentColor, outlineEnabled);
return applyActionBarDrawable(context, d, isTransparentBackground(themeRes));
final int actionBarColor;
if (isDarkTheme(themeRes)) {
actionBarColor = context.getResources().getColor(R.color.background_color_action_bar_dark);
} else {
actionBarColor = accentColor;
}
final TypedArray a = context.obtainStyledAttributes(null, new int[]{android.R.attr.background},
android.R.attr.actionBarStyle, themeRes);
final Drawable d = a.getDrawable(0);
a.recycle();
final ColorDrawable d = new ActionBarColorDrawable(actionBarColor, outlineEnabled);
return applyActionBarDrawable(context, d, isTransparentBackground(themeRes));
}
@NonNull
public static Drawable getActionBarStackedBackground(final Context context, final int themeRes,
final int accentColor, boolean outlineEnabled) {
final int actionBarColor;
if (isDarkTheme(themeRes)) {
actionBarColor = context.getResources().getColor(R.color.background_color_action_bar_dark);
} else {
actionBarColor = accentColor;
}
final ColorDrawable d = new ActionBarColorDrawable(actionBarColor, outlineEnabled);
return applyActionBarDrawable(context, d, isTransparentBackground(themeRes));
}
@ -451,23 +475,6 @@ public class ThemeUtils implements Constants {
return applyActionBarDrawable(context, d, isTransparentBackground(themeRes));
}
@Deprecated
public static Drawable getActionBarStackedBackground(final Context context, final boolean applyAlpha) {
final TypedArray a = context.obtainStyledAttributes(null, new int[]{android.R.attr.backgroundStacked},
android.R.attr.actionBarStyle, 0);
final Drawable d = a.getDrawable(0);
a.recycle();
return applyActionBarDrawable(context, d, applyAlpha);
}
public static Drawable getActionBarStackedBackground(final Context context, final int themeRes) {
final TypedArray a = context.obtainStyledAttributes(null, new int[]{android.R.attr.backgroundStacked},
android.R.attr.actionBarStyle, themeRes);
final Drawable d = a.getDrawable(0);
a.recycle();
return applyActionBarDrawable(context, d, isTransparentBackground(themeRes));
}
public static int getActionIconColor(final int themeRes) {
switch (themeRes) {
case R.style.Theme_Twidere_Light:

View File

@ -24,6 +24,7 @@ import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.widget.ImageView;
@ -113,7 +114,7 @@ public class ForegroundImageView extends ImageView implements IForegroundView {
}
@Override
protected void onDraw(final Canvas canvas) {
protected void onDraw(@NonNull final Canvas canvas) {
super.onDraw(canvas);
mForegroundViewHelper.dispatchOnDraw(canvas);
}

View File

@ -85,7 +85,11 @@ public class HomeActionButton extends FrameLayout implements IHomeActionButton {
final Resources resources = context.getResources();
final float elevation = resources.getDisplayMetrics().density * 4;
mHelper = new EffectViewHelper(this, new PressElevationProperty(elevation), 200);
inflate(ThemeUtils.getActionBarContext(context), R.layout.action_item_home_actions, this);
if (isInEditMode()) {
inflate(context, R.layout.action_item_home_actions, this);
} else {
inflate(ThemeUtils.getActionBarContext(context), R.layout.action_item_home_actions, this);
}
mIconView = (ImageView) findViewById(android.R.id.icon);
mProgressBar = (ProgressBar) findViewById(android.R.id.progress);
ViewAccessor.setOutlineProvider(this, new HomeActionButtonOutlineProvider());

View File

@ -45,11 +45,6 @@ public class StatusComposeEditText extends ThemedMultiAutoCompleteTextView imple
public StatusComposeEditText(final Context context, final AttributeSet attrs, final int defStyle) {
super(context, attrs, defStyle);
if (isInEditMode()) {
mAdapter = null;
} else {
mAdapter = new UserHashtagAutoCompleteAdapter(this);
}
setTokenizer(new ScreenNameTokenizer());
setMovementMethod(ArrowKeyMovementMethod.getInstance());
setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
@ -69,7 +64,7 @@ public class StatusComposeEditText extends ThemedMultiAutoCompleteTextView imple
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (mAdapter == null || mAdapter.isCursorClosed()) {
if (!isInEditMode() && mAdapter == null || mAdapter.isCursorClosed()) {
mAdapter = new UserHashtagAutoCompleteAdapter(this);
}
setAdapter(mAdapter);

View File

@ -120,7 +120,7 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator {
@Override
public void onPageSelected(int position) {
mIndicatorAdapter.notifyDataSetChanged();
notifyDataSetChanged();
if (mPageChangeListener == null) return;
smoothScrollToPosition(position);
mPageChangeListener.onPageSelected(position);
@ -395,6 +395,12 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator {
}
}
public void updateAppearance() {
final int positionStart = mLayoutManager.findFirstVisibleItemPosition();
final int itemCount = mLayoutManager.findLastVisibleItemPosition() - positionStart;
mIndicatorAdapter.notifyItemRangeChanged(positionStart, itemCount);
}
private static class TabPagerIndicatorAdapter extends Adapter<TabItemHolder> {
private final TabPagerIndicator mIndicator;
@ -424,7 +430,11 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator {
public TabItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (mIndicator == null) throw new IllegalStateException("item context not set");
final View view = mInflater.inflate(R.layout.layout_tab_item, parent, false);
return new TabItemHolder(mIndicator, view);
final TabItemHolder holder = new TabItemHolder(mIndicator, view);
holder.setStripHeight(mIndicator.getStripHeight());
holder.setPadding(mIndicator.getTabHorizontalPadding(), mIndicator.getTabVerticalPadding());
holder.setDisplayOption(mIndicator.isIconDisplayed(), mIndicator.isLabelDisplayed());
return holder;
}
@Override
@ -432,13 +442,11 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator {
final Drawable icon = mTabProvider.getPageIcon(position);
final CharSequence title = mTabProvider.getPageTitle(position);
holder.setTabData(icon, title, mIndicator.getCurrentItem() == position);
holder.setPadding(mIndicator.getTabHorizontalPadding(), mIndicator.getTabVerticalPadding());
holder.setStripHeight(mIndicator.getStripHeight());
holder.setBadge(mUnreadCounts.get(position, 0), mDisplayBadge);
holder.setStripColor(mStripColor);
holder.setIconColor(mIconColor);
holder.setLabelColor(mLabelColor);
holder.setBadge(mUnreadCounts.get(position, 0), mDisplayBadge);
holder.setDisplayOption(mIndicator.isIconDisplayed(), mIndicator.isLabelDisplayed());
}
@Override
@ -449,17 +457,17 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator {
public void setBadge(int position, int count) {
mUnreadCounts.put(position, count);
notifyDataSetChanged();
notifyItemChanged(position);
}
public void setDisplayBadge(boolean display) {
mDisplayBadge = display;
notifyDataSetChanged();
// notifyDataSetChanged();
}
public void setIconColor(int color) {
mIconColor = color;
notifyDataSetChanged();
// notifyDataSetChanged();
}
public void setLabelColor(int color) {
@ -469,12 +477,12 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator {
public void setStripColor(int color) {
mStripColor = color;
notifyDataSetChanged();
// notifyDataSetChanged();
}
public void setTabProvider(TabProvider tabProvider) {
mTabProvider = tabProvider;
notifyDataSetChanged();
// notifyDataSetChanged();
}
}
}

View File

@ -85,9 +85,9 @@ public class MessageEntryViewHolder extends ViewHolder implements OnClickListene
} else {
timeView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
}
nameView.setTypeface(null, isUnread ? Typeface.BOLD : Typeface.NORMAL);
screenNameView.setTypeface(null, isUnread ? Typeface.BOLD : Typeface.NORMAL);
textView.setTypeface(null, isUnread ? Typeface.BOLD : Typeface.NORMAL);
nameView.setTypeface(null, isUnread && !isOutgoing ? Typeface.BOLD : Typeface.NORMAL);
screenNameView.setTypeface(null, isUnread && !isOutgoing ? Typeface.BOLD : Typeface.NORMAL);
textView.setTypeface(null, isUnread && !isOutgoing ? Typeface.BOLD : Typeface.NORMAL);
if (account_color_enabled) {
content.drawEnd(Utils.getAccountColor(context, accountId));
}

View File

@ -85,7 +85,7 @@ public interface IForegroundView {
setForeground(d);
}
mForegroundInPadding = true;
// mForegroundInPadding = true;
a.recycle();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@ -54,6 +54,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/view_pager_tabs"/>
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/view_pager"
android:layout_alignTop="@+id/view_pager"
android:background="?android:windowContentOverlay"/>
</RelativeLayout>
<LinearLayout

View File

@ -74,24 +74,30 @@
android:paddingRight="@dimen/element_spacing_normal"
android:scrollbarStyle="outsideInset"/>
<FrameLayout
<LinearLayout
android:id="@+id/users_search_empty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:paddingLeft="@dimen/element_spacing_normal"
android:paddingRight="@dimen/element_spacing_normal">
<LinearLayout
<org.mariotaku.twidere.view.ActionIconView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
android:color="?android:textColorSecondary"
android:src="@drawable/ic_info_search"/>
<TextView
android:id="@+id/users_search_empty_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</FrameLayout>
<TextView
android:id="@+id/users_search_empty_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/element_spacing_normal"
android:gravity="center"
android:textAppearance="?android:textAppearanceMedium"/>
</LinearLayout>
<ProgressBar
android:id="@+id/users_search_progress"

View File

@ -75,7 +75,7 @@
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="?android:colorActivatedHighlight"
android:textSize="@dimen/text_size_wizard_nav_item"
android:textStyle="bold|italic"/>
android:textStyle="bold"/>
</FrameLayout>
</LinearLayout>

View File

@ -117,7 +117,238 @@
android:id="@+id/profile_details_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/profile_name_container"/>
android:layout_below="@+id/profile_name_container">
<LinearLayout
android:id="@+id/card_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:splitMotionEvents="false">
<LinearLayout
android:id="@+id/description_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:orientation="vertical"
android:padding="@dimen/element_spacing_small">
<org.mariotaku.twidere.view.themed.ThemedTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/element_spacing_small"
android:singleLine="true"
android:text="@string/description"
android:textAllCaps="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:textColorPrimary"
android:textStyle="bold"
android:visibility="gone"/>
<org.mariotaku.twidere.view.HandleSpanClickTextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/element_spacing_small"
android:paddingRight="@dimen/element_spacing_small"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="?android:textColorPrimary"
tools:text="Line 1\nLine 2\nLine 3"/>
</LinearLayout>
<LinearLayout
android:id="@+id/location_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/element_spacing_small">
<org.mariotaku.twidere.view.ActionIconView
android:layout_width="@dimen/element_size_small"
android:layout_height="@dimen/element_size_small"
android:color="?android:textColorPrimary"
android:src="@drawable/ic_action_location"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/element_spacing_small"
android:paddingRight="@dimen/element_spacing_small"
android:singleLine="true"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="?android:textColorPrimary"
tools:text="Zhengzhou China"/>
</LinearLayout>
<LinearLayout
android:id="@+id/url_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/element_spacing_small">
<org.mariotaku.twidere.view.ActionIconView
android:layout_width="@dimen/element_size_small"
android:layout_height="@dimen/element_size_small"
android:color="?android:textColorPrimary"
android:src="@drawable/ic_action_link"/>
<org.mariotaku.twidere.view.HandleSpanClickTextView
android:id="@+id/url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:paddingLeft="@dimen/element_spacing_small"
android:paddingRight="@dimen/element_spacing_small"
android:singleLine="true"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="?android:textColorPrimary"
tools:text="mariotaku.org"/>
</LinearLayout>
<LinearLayout
android:id="@+id/created_at_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/element_spacing_small">
<org.mariotaku.twidere.view.ActionIconView
android:layout_width="@dimen/element_size_small"
android:layout_height="@dimen/element_size_small"
android:color="?android:textColorPrimary"
android:src="@drawable/ic_action_portal_cake"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/created_at"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/element_spacing_small"
android:paddingRight="@dimen/element_spacing_small"
android:singleLine="true"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="?android:textColorPrimary"
tools:text="July 17, 2009 18:35 (20 tweets per day)"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.2dp"
android:background="?android:dividerVertical"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/action_button_size"
android:baselineAligned="false"
android:divider="?android:dividerHorizontal"
android:orientation="horizontal"
android:showDividers="middle"
android:splitMotionEvents="false">
<LinearLayout
android:id="@+id/followers_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:gravity="center"
android:orientation="vertical"
android:padding="@dimen/element_spacing_small">
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/followers_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="?android:textColorPrimary"
tools:text="255"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="@string/followers"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="?android:textColorSecondary"/>
</LinearLayout>
<LinearLayout
android:id="@+id/friends_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:gravity="center"
android:orientation="vertical"
android:padding="@dimen/element_spacing_small">
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/friends_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="?android:textColorPrimary"
tools:text="255"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="@string/following"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="?android:textColorSecondary"/>
</LinearLayout>
<LinearLayout
android:id="@+id/listed_container"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:gravity="center"
android:orientation="vertical"
android:padding="@dimen/element_spacing_small">
<org.mariotaku.twidere.view.themed.ThemedTextView
android:id="@+id/listed_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="?android:textColorPrimary"
tools:text="255"/>
<org.mariotaku.twidere.view.themed.ThemedTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="@string/listed"
android:textAppearance="?android:textAppearanceSmall"
android:textColor="?android:textColorSecondary"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<include layout="@layout/layout_content_fragment_common"/>
</FrameLayout>
<org.mariotaku.twidere.view.ShapedImageView
android:id="@+id/profile_image"
@ -145,11 +376,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/profile_details_container"
android:alpha="0.2"
android:gravity="center"
android:padding="@dimen/element_spacing_small"
android:text="@string/uucky_footer_text"
android:textColor="?android:textColorPrimary"
android:textColor="?android:textColorTertiary"
android:textSize="10sp"
android:textStyle="italic"
android:typeface="serif"

View File

@ -34,8 +34,7 @@
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="?android:colorActivatedHighlight"
android:textSize="@dimen/text_size_wizard_title"
android:textStyle="italic"/>
android:textSize="@dimen/text_size_wizard_title"/>
<TextView
android:id="@android:id/summary"

View File

@ -31,6 +31,6 @@
android:layout_gravity="center"
android:text="@string/click_item_to_config"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textStyle="bold|italic"/>
android:textStyle="bold"/>
</FrameLayout>

View File

@ -34,6 +34,6 @@
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="?android:colorActivatedHighlight"
android:textSize="@dimen/text_size_wizard_nav_item"
android:textStyle="bold|italic"/>
android:textStyle="bold"/>
</FrameLayout>

View File

@ -30,5 +30,6 @@
<color name="bg_color_media_viewer">#a0000000</color>
<color name="background_color_card_item_dark">#1a1a1a</color>
<color name="background_color_card_item_light">#fafafa</color>
<color name="background_color_action_bar_dark">#212121</color>
</resources>