added toolbar color for Chrome Custom Tab
This commit is contained in:
parent
a741047c6e
commit
f755c2ef20
|
@ -378,7 +378,7 @@ public class Chameleon {
|
||||||
theme.setColorEdgeEffect(a.getColor(R.styleable.ChameleonTheme_colorEdgeEffect, 0));
|
theme.setColorEdgeEffect(a.getColor(R.styleable.ChameleonTheme_colorEdgeEffect, 0));
|
||||||
|
|
||||||
theme.setColorControlNormal(a.getColor(R.styleable.ChameleonTheme_colorControlNormal, 0));
|
theme.setColorControlNormal(a.getColor(R.styleable.ChameleonTheme_colorControlNormal, 0));
|
||||||
theme.setColorControlActivated(a.getColor(R.styleable.ChameleonTheme_colorControlNormal, 0));
|
theme.setColorControlActivated(a.getColor(R.styleable.ChameleonTheme_colorControlActivated, 0));
|
||||||
|
|
||||||
theme.setStatusBarColor(a.getColor(R.styleable.ChameleonTheme_android_statusBarColor, 0));
|
theme.setStatusBarColor(a.getColor(R.styleable.ChameleonTheme_android_statusBarColor, 0));
|
||||||
theme.setNavigationBarColor(a.getColor(R.styleable.ChameleonTheme_android_navigationBarColor, Color.BLACK));
|
theme.setNavigationBarColor(a.getColor(R.styleable.ChameleonTheme_android_navigationBarColor, Color.BLACK));
|
||||||
|
|
|
@ -55,27 +55,30 @@ public class ChameleonTypedArray {
|
||||||
|
|
||||||
public int getColor(int index, int defValue) {
|
public int getColor(int index, int defValue) {
|
||||||
final int ref = attributeReferences[index];
|
final int ref = attributeReferences[index];
|
||||||
if (ref == android.support.design.R.attr.colorPrimary) {
|
int color = getCommonColorReference(ref);
|
||||||
return theme.getColorPrimary();
|
if (color != 0) return color;
|
||||||
} else if (ref == android.support.design.R.attr.colorAccent) {
|
|
||||||
return theme.getColorAccent();
|
|
||||||
} else if (ref == R.attr.colorToolbar) {
|
|
||||||
return theme.getColorToolbar();
|
|
||||||
}
|
|
||||||
if (!hasAttributeStates[index]) return defValue;
|
if (!hasAttributeStates[index]) return defValue;
|
||||||
return wrapped.getColor(index, defValue);
|
return wrapped.getColor(index, defValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drawable getDrawable(int index) {
|
public Drawable getDrawable(int index) {
|
||||||
final int ref = attributeReferences[index];
|
final int ref = attributeReferences[index];
|
||||||
if (ref == android.support.design.R.attr.colorPrimary) {
|
int color = getCommonColorReference(ref);
|
||||||
return new ColorDrawable(theme.getColorPrimary());
|
if (color != 0) return new ColorDrawable(color);
|
||||||
} else if (ref == android.support.design.R.attr.colorAccent) {
|
|
||||||
return new ColorDrawable(theme.getColorAccent());
|
|
||||||
} else if (ref == R.attr.colorToolbar) {
|
|
||||||
return new ColorDrawable(theme.getColorToolbar());
|
|
||||||
}
|
|
||||||
if (!hasAttributeStates[index]) return null;
|
if (!hasAttributeStates[index]) return null;
|
||||||
return wrapped.getDrawable(index);
|
return wrapped.getDrawable(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCommonColorReference(int ref) {
|
||||||
|
if (ref == android.support.design.R.attr.colorPrimary) {
|
||||||
|
return theme.getColorPrimary();
|
||||||
|
} else if (ref == android.support.design.R.attr.colorPrimaryDark) {
|
||||||
|
return theme.getColorPrimaryDark();
|
||||||
|
} else if (ref == android.support.design.R.attr.colorAccent) {
|
||||||
|
return theme.getColorAccent();
|
||||||
|
} else if (ref == R.attr.colorToolbar) {
|
||||||
|
return theme.getColorToolbar();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,13 @@ import android.content.res.TypedArray;
|
||||||
import android.graphics.PorterDuff.Mode;
|
import android.graphics.PorterDuff.Mode;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.support.annotation.ColorInt;
|
import android.support.annotation.ColorInt;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.widget.AppCompatTextView;
|
import android.support.v7.widget.AppCompatTextView;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import org.mariotaku.chameleon.Chameleon;
|
||||||
|
import org.mariotaku.chameleon.ChameleonView;
|
||||||
import org.mariotaku.twidere.R;
|
import org.mariotaku.twidere.R;
|
||||||
import org.mariotaku.twidere.util.support.TextViewSupport;
|
import org.mariotaku.twidere.util.support.TextViewSupport;
|
||||||
import org.mariotaku.twidere.view.iface.IIconActionButton;
|
import org.mariotaku.twidere.view.iface.IIconActionButton;
|
||||||
|
@ -139,4 +143,19 @@ public class ActionIconThemedTextView extends AppCompatTextView implements IIcon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPostApplyTheme() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Appearance createAppearance(@NonNull Context context, @NonNull AttributeSet attributeSet, @NonNull Chameleon.Theme theme) {
|
||||||
|
return IIconActionButton.Appearance.create(context, attributeSet, theme);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyAppearance(@NonNull ChameleonView.Appearance appearance) {
|
||||||
|
IIconActionButton.Appearance.apply(this, (Appearance) appearance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,14 @@ import android.content.res.ColorStateList;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.support.annotation.ColorInt;
|
import android.support.annotation.ColorInt;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.view.ViewCompat;
|
import android.support.v4.view.ViewCompat;
|
||||||
import android.support.v7.widget.AppCompatImageButton;
|
import android.support.v7.widget.AppCompatImageButton;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import org.mariotaku.chameleon.Chameleon;
|
||||||
|
import org.mariotaku.chameleon.ChameleonView;
|
||||||
import org.mariotaku.twidere.R;
|
import org.mariotaku.twidere.R;
|
||||||
import org.mariotaku.twidere.util.ThemeUtils;
|
import org.mariotaku.twidere.util.ThemeUtils;
|
||||||
import org.mariotaku.twidere.view.iface.IIconActionButton;
|
import org.mariotaku.twidere.view.iface.IIconActionButton;
|
||||||
|
@ -107,4 +111,20 @@ public class IconActionButton extends AppCompatImageButton implements IIconActio
|
||||||
setColorFilter(getDisabledColor());
|
setColorFilter(getDisabledColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPostApplyTheme() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Appearance createAppearance(@NonNull Context context, @NonNull AttributeSet attributeSet, @NonNull Chameleon.Theme theme) {
|
||||||
|
return IIconActionButton.Appearance.create(context, attributeSet, theme);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyAppearance(@NonNull ChameleonView.Appearance appearance) {
|
||||||
|
IIconActionButton.Appearance.apply(this, (Appearance) appearance);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,14 @@ import android.content.res.ColorStateList;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.support.annotation.ColorInt;
|
import android.support.annotation.ColorInt;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.view.ViewCompat;
|
import android.support.v4.view.ViewCompat;
|
||||||
import android.support.v7.widget.AppCompatImageView;
|
import android.support.v7.widget.AppCompatImageView;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import org.mariotaku.chameleon.Chameleon;
|
||||||
|
import org.mariotaku.chameleon.ChameleonView;
|
||||||
import org.mariotaku.twidere.R;
|
import org.mariotaku.twidere.R;
|
||||||
import org.mariotaku.twidere.util.ThemeUtils;
|
import org.mariotaku.twidere.util.ThemeUtils;
|
||||||
import org.mariotaku.twidere.view.iface.IIconActionButton;
|
import org.mariotaku.twidere.view.iface.IIconActionButton;
|
||||||
|
@ -101,4 +105,21 @@ public class IconActionView extends AppCompatImageView implements IIconActionBut
|
||||||
setColorFilter(getDisabledColor());
|
setColorFilter(getDisabledColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPostApplyTheme() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Appearance createAppearance(@NonNull Context context, @NonNull AttributeSet attributeSet, @NonNull Chameleon.Theme theme) {
|
||||||
|
return IIconActionButton.Appearance.create(context, attributeSet, theme);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyAppearance(@NonNull ChameleonView.Appearance appearance) {
|
||||||
|
IIconActionButton.Appearance.apply(this, (Appearance) appearance);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
* Twidere - Twitter client for Android
|
|
||||||
*
|
|
||||||
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.mariotaku.twidere.view;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
public class SquareIconActionButton extends IconActionButton {
|
|
||||||
|
|
||||||
public SquareIconActionButton(final Context context) {
|
|
||||||
this(context, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SquareIconActionButton(final Context context, final AttributeSet attrs) {
|
|
||||||
this(context, attrs, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SquareIconActionButton(final Context context, final AttributeSet attrs, final int defStyle) {
|
|
||||||
super(context, attrs, defStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
|
|
||||||
final int width = MeasureSpec.getSize(widthMeasureSpec), height = MeasureSpec.getSize(heightMeasureSpec);
|
|
||||||
final ViewGroup.LayoutParams lp = getLayoutParams();
|
|
||||||
if (lp.height == ViewGroup.LayoutParams.MATCH_PARENT && lp.width == ViewGroup.LayoutParams.WRAP_CONTENT) {
|
|
||||||
super.onMeasure(heightMeasureSpec, heightMeasureSpec);
|
|
||||||
setMeasuredDimension(height, height);
|
|
||||||
} else if (lp.width == ViewGroup.LayoutParams.MATCH_PARENT && lp.height == ViewGroup.LayoutParams.WRAP_CONTENT) {
|
|
||||||
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
|
|
||||||
setMeasuredDimension(width, width);
|
|
||||||
} else {
|
|
||||||
if (width > height) {
|
|
||||||
super.onMeasure(heightMeasureSpec, heightMeasureSpec);
|
|
||||||
setMeasuredDimension(height, height);
|
|
||||||
} else {
|
|
||||||
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
|
|
||||||
setMeasuredDimension(width, width);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,11 +1,18 @@
|
||||||
package org.mariotaku.twidere.view.iface;
|
package org.mariotaku.twidere.view.iface;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.support.annotation.ColorInt;
|
import android.support.annotation.ColorInt;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import org.mariotaku.chameleon.Chameleon;
|
||||||
|
import org.mariotaku.chameleon.ChameleonView;
|
||||||
|
import org.mariotaku.chameleon.internal.ChameleonTypedArray;
|
||||||
|
import org.mariotaku.twidere.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mariotaku on 16/3/19.
|
* Created by mariotaku on 16/3/19.
|
||||||
*/
|
*/
|
||||||
public interface IIconActionButton {
|
public interface IIconActionButton extends ChameleonView {
|
||||||
@ColorInt
|
@ColorInt
|
||||||
int getDefaultColor();
|
int getDefaultColor();
|
||||||
|
|
||||||
|
@ -20,4 +27,50 @@ public interface IIconActionButton {
|
||||||
void setActivatedColor(@ColorInt int activatedColor);
|
void setActivatedColor(@ColorInt int activatedColor);
|
||||||
|
|
||||||
void setDisabledColor(@ColorInt int disabledColor);
|
void setDisabledColor(@ColorInt int disabledColor);
|
||||||
|
|
||||||
|
|
||||||
|
class Appearance implements ChameleonView.Appearance {
|
||||||
|
@ColorInt
|
||||||
|
private int defaultColor, activatedColor, disabledColor;
|
||||||
|
|
||||||
|
public int getActivatedColor() {
|
||||||
|
return activatedColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivatedColor(int activatedColor) {
|
||||||
|
this.activatedColor = activatedColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDefaultColor() {
|
||||||
|
return defaultColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultColor(int defaultColor) {
|
||||||
|
this.defaultColor = defaultColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDisabledColor() {
|
||||||
|
return disabledColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisabledColor(int disabledColor) {
|
||||||
|
this.disabledColor = disabledColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Appearance create(Context context, AttributeSet attributeSet, Chameleon.Theme theme) {
|
||||||
|
Appearance appearance = new Appearance();
|
||||||
|
ChameleonTypedArray a = ChameleonTypedArray.obtain(context, attributeSet, R.styleable.IconActionButton, theme);
|
||||||
|
appearance.setDefaultColor(a.getColor(R.styleable.IconActionButton_iabColor, theme.getColorForeground()));
|
||||||
|
appearance.setActivatedColor(a.getColor(R.styleable.IconActionButton_iabActivatedColor, theme.getColorAccent()));
|
||||||
|
appearance.setActivatedColor(a.getColor(R.styleable.IconActionButton_iabDisabledColor, theme.getTextColorSecondary()));
|
||||||
|
a.recycle();
|
||||||
|
return appearance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void apply(IIconActionButton view, Appearance appearance) {
|
||||||
|
view.setDefaultColor(appearance.getDefaultColor());
|
||||||
|
view.setActivatedColor(appearance.getActivatedColor());
|
||||||
|
view.setDisabledColor(appearance.getDisabledColor());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ import android.support.customtabs.CustomTabsIntent
|
||||||
import edu.tsinghua.hotmobi.HotMobiLogger
|
import edu.tsinghua.hotmobi.HotMobiLogger
|
||||||
import edu.tsinghua.hotmobi.model.LinkEvent
|
import edu.tsinghua.hotmobi.model.LinkEvent
|
||||||
import org.apache.commons.lang3.StringUtils
|
import org.apache.commons.lang3.StringUtils
|
||||||
|
import org.mariotaku.chameleon.Chameleon
|
||||||
|
import org.mariotaku.chameleon.ChameleonUtils
|
||||||
import org.mariotaku.twidere.activity.WebLinkHandlerActivity
|
import org.mariotaku.twidere.activity.WebLinkHandlerActivity
|
||||||
import org.mariotaku.twidere.annotation.Referral
|
import org.mariotaku.twidere.annotation.Referral
|
||||||
import org.mariotaku.twidere.app.TwidereApplication
|
import org.mariotaku.twidere.app.TwidereApplication
|
||||||
|
@ -159,6 +161,9 @@ open class OnLinkClickHandler(
|
||||||
protected open fun openLink(link: String) {
|
protected open fun openLink(link: String) {
|
||||||
if (manager != null && manager.isActive) return
|
if (manager != null && manager.isActive) return
|
||||||
val builder = CustomTabsIntent.Builder()
|
val builder = CustomTabsIntent.Builder()
|
||||||
|
(ChameleonUtils.getActivity(context) as? Chameleon.Themeable)?.overrideTheme?.let { theme ->
|
||||||
|
builder.setToolbarColor(theme.colorToolbar)
|
||||||
|
}
|
||||||
val intent = builder.build()
|
val intent = builder.build()
|
||||||
try {
|
try {
|
||||||
intent.launchUrl(context, Uri.parse(link))
|
intent.launchUrl(context, Uri.parse(link))
|
||||||
|
|
|
@ -48,9 +48,9 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?android:panelColorBackground"
|
android:background="?android:panelColorBackground"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
android:padding="@dimen/element_spacing_normal"
|
android:padding="@dimen/element_spacing_normal"
|
||||||
tools:text="In reply to name: A quick brown fox jumps over the lazy dog"
|
tools:text="In reply to name: A quick brown fox jumps over the lazy dog"/>
|
||||||
android:maxLines="1"/>
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/replyLabelDivider"
|
android:id="@+id/replyLabelDivider"
|
||||||
|
@ -97,7 +97,6 @@
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:src="@drawable/ic_action_location"
|
android:src="@drawable/ic_action_location"
|
||||||
android:tag="iab_activated_color|accent_color"
|
|
||||||
app:iabActivatedColor="?colorAccent"
|
app:iabActivatedColor="?colorAccent"
|
||||||
app:iabColor="?android:textColorSecondary"
|
app:iabColor="?android:textColorSecondary"
|
||||||
tools:activated="true"/>
|
tools:activated="true"/>
|
||||||
|
@ -113,10 +112,10 @@
|
||||||
android:layout_toLeftOf="@+id/locationSwitch"
|
android:layout_toLeftOf="@+id/locationSwitch"
|
||||||
android:layout_toRightOf="@+id/locationIcon"
|
android:layout_toRightOf="@+id/locationIcon"
|
||||||
android:layout_toStartOf="@+id/locationSwitch"
|
android:layout_toStartOf="@+id/locationSwitch"
|
||||||
|
android:maxLines="1"
|
||||||
android:paddingLeft="@dimen/element_spacing_normal"
|
android:paddingLeft="@dimen/element_spacing_normal"
|
||||||
android:paddingRight="@dimen/element_spacing_normal"
|
android:paddingRight="@dimen/element_spacing_normal"
|
||||||
tools:text="11.4, 51.4"
|
tools:text="11.4, 51.4"/>
|
||||||
android:maxLines="1"/>
|
|
||||||
|
|
||||||
<org.mariotaku.twidere.view.ThemedMultiValueSwitch
|
<org.mariotaku.twidere.view.ThemedMultiValueSwitch
|
||||||
android:id="@+id/locationSwitch"
|
android:id="@+id/locationSwitch"
|
||||||
|
@ -230,8 +229,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:background="@null"
|
android:background="@null"/>
|
||||||
android:tag="ate_ignore"/>
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
Loading…
Reference in New Issue