mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-01-31 08:54:57 +01:00
fixed overflow icon sometimes not applied to theme color
This commit is contained in:
parent
e99a370146
commit
85aa0299ab
@ -23,12 +23,18 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.support.v4.view.LayoutInflaterCompat;
|
||||
import android.support.v7.widget.ActionMenuView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Window;
|
||||
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.util.ThemeUtils;
|
||||
import org.mariotaku.twidere.util.ThemedLayoutInflaterFactory;
|
||||
import org.mariotaku.twidere.util.support.ViewSupport;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* Created by mariotaku on 15/4/22.
|
||||
@ -54,9 +60,33 @@ public class ThemedAppCompatDelegate implements Constants {
|
||||
|
||||
private final IThemedActivity themed;
|
||||
|
||||
private ThemedAppCompatDelegateImplV11(IThemedActivity themed, Context context, Window window, AppCompatCallback callback) {
|
||||
private ThemedAppCompatDelegateImplV11(final IThemedActivity themed, final Context context,
|
||||
Window window, AppCompatCallback callback) {
|
||||
super(context, window, callback);
|
||||
this.themed = themed;
|
||||
// try {
|
||||
// final Field field = AppCompatDelegateImplV7.class.getDeclaredField("mInvalidatePanelMenuRunnable");
|
||||
// field.setAccessible(true);
|
||||
// final Runnable old = (Runnable) field.get(this);
|
||||
// field.set(this, new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// if (old != null) {
|
||||
// old.run();
|
||||
// }
|
||||
// final int themeColor = themed.getCurrentThemeColor();
|
||||
// final int themeId = themed.getCurrentThemeResourceId();
|
||||
// final int itemColor = ThemeUtils.getContrastActionBarItemColor(context, themeId, themeColor);
|
||||
// final Toolbar toolbar = ThemeUtils.getToolbarFromActivity((Activity) themed);
|
||||
// if (toolbar != null) {
|
||||
// ThemeUtils.setActionBarOverflowColor(toolbar, itemColor);
|
||||
// ThemeUtils.wrapToolbarMenuIcon(ViewSupport.findViewByType(toolbar, ActionMenuView.class), itemColor, itemColor);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// } catch (Exception ignore) {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -234,9 +234,21 @@ public class LinkHandlerActivity extends BaseAppCompatActivity implements System
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
final boolean result = super.onPrepareOptionsMenu(menu);
|
||||
if (!shouldSetActionItemColor()) return result;
|
||||
public boolean onPreparePanel(int featureId, View view, Menu menu) {
|
||||
final boolean result = super.onPreparePanel(featureId, view, menu);
|
||||
if (shouldSetActionItemColor()) {
|
||||
setupToolbarMenuItemColor();
|
||||
mActionBarContainer.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setupToolbarMenuItemColor();
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void setupToolbarMenuItemColor() {
|
||||
final Toolbar toolbar = peekActionBarToolbar();
|
||||
if (toolbar != null) {
|
||||
final int themeColor = getCurrentThemeColor();
|
||||
@ -245,7 +257,6 @@ public class LinkHandlerActivity extends BaseAppCompatActivity implements System
|
||||
ThemeUtils.setActionBarOverflowColor(toolbar, itemColor);
|
||||
ThemeUtils.wrapToolbarMenuIcon(ViewSupport.findViewByType(toolbar, ActionMenuView.class), itemColor, itemColor);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public final void setSubtitle(CharSequence subtitle) {
|
||||
|
@ -65,9 +65,9 @@ public class SearchFragment extends BaseSupportFragment implements RefreshScroll
|
||||
|
||||
private ViewPager mViewPager;
|
||||
private View mPagerWindowOverlay;
|
||||
private TabPagerIndicator mPagerIndicator;
|
||||
|
||||
private SupportTabsAdapter mPagerAdapter;
|
||||
private TabPagerIndicator mPagerIndicator;
|
||||
|
||||
private int mControlBarOffsetPixels;
|
||||
private int mControlBarHeight;
|
||||
|
@ -71,6 +71,7 @@ import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.mariotaku.twidere.Constants;
|
||||
import org.mariotaku.twidere.R;
|
||||
import org.mariotaku.twidere.activity.iface.IThemedActivity;
|
||||
import org.mariotaku.twidere.activity.support.LinkHandlerActivity;
|
||||
import org.mariotaku.twidere.graphic.ActionBarColorDrawable;
|
||||
import org.mariotaku.twidere.graphic.ActionIconDrawable;
|
||||
import org.mariotaku.twidere.text.ParagraphSpacingSpan;
|
||||
@ -1070,9 +1071,7 @@ public class ThemeUtils implements Constants {
|
||||
}
|
||||
}
|
||||
if (!(overflowView instanceof ImageView)) return;
|
||||
final Drawable drawable = ((ImageView) overflowView).getDrawable();
|
||||
if (drawable == null) return;
|
||||
drawable.setColorFilter(itemColor, Mode.SRC_ATOP);
|
||||
((ImageView) overflowView).setColorFilter(itemColor, Mode.SRC_ATOP);
|
||||
}
|
||||
|
||||
public static void setActionBarOverflowColor(ActionMenuView actionMenuView, int itemColor) {
|
||||
@ -1262,4 +1261,11 @@ public class ThemeUtils implements Constants {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Toolbar getToolbarFromActivity(Activity activity) {
|
||||
if (activity instanceof LinkHandlerActivity)
|
||||
return ((LinkHandlerActivity) activity).peekActionBarToolbar();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user