improved theme color

This commit is contained in:
Mariotaku Lee 2017-02-05 11:13:28 +08:00
parent 253e46a5b1
commit ca1ccec481
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
4 changed files with 38 additions and 5 deletions

View File

@ -0,0 +1,35 @@
package org.mariotaku.twidere.view;
import android.content.Context;
import android.content.res.ColorStateList;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import org.jetbrains.annotations.NotNull;
import org.mariotaku.chameleon.Chameleon;
import org.mariotaku.chameleon.ChameleonUtils;
/**
* Created by mariotaku on 2016/12/23.
*/
public class PreferencesItemTextView extends FixedTextView {
private static final int[] ACTIVATED_STATE_SET = {android.R.attr.state_activated};
private static final int[] EMPTY_STATE_SET = {0};
public PreferencesItemTextView(@NotNull final Context context, @Nullable final AttributeSet attrs) {
super(context, attrs);
}
@Nullable
@Override
public Appearance createAppearance(@NonNull Context context, @NonNull AttributeSet attributeSet, @NonNull Chameleon.Theme theme) {
Appearance appearance = new Appearance();
final int activatedColor = ChameleonUtils.getColorDependent(theme.getColorControlActivated());
final int defaultColor = theme.getTextColorPrimary();
appearance.setTextColor(new ColorStateList(new int[][]{ACTIVATED_STATE_SET, EMPTY_STATE_SET}, new int[]{activatedColor, defaultColor}));
return appearance;
}
}

View File

@ -177,9 +177,7 @@ class SettingsActivity : BaseActivity(), OnItemClickListener, OnPreferenceStartF
}
private val isTopSettings: Boolean
get() = java.lang.Boolean.parseBoolean("true")
private val isTopSettings: Boolean = true
private fun initEntries() {
entriesAdapter.addHeader(getString(R.string.appearance))

View File

@ -8,7 +8,7 @@ import org.mariotaku.chameleon.view.ChameleonTextView
* Created by mariotaku on 2017/2/3.
*/
class FixedTextView(context: Context, attrs: AttributeSet? = null) : ChameleonTextView(context, attrs) {
open class FixedTextView(context: Context, attrs: AttributeSet? = null) : ChameleonTextView(context, attrs) {
override fun onTextContextMenuItem(id: Int): Boolean {
try {

View File

@ -42,7 +42,7 @@
app:iabColor="?android:colorForeground"
tools:src="@drawable/ic_action_settings"/>
<org.mariotaku.twidere.view.FixedTextView
<org.mariotaku.twidere.view.PreferencesItemTextView
android:id="@android:id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"