From 47eaf41e497280be5f32e0463f02b765119f9ae1 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Fri, 14 Apr 2017 22:17:20 +0800 Subject: [PATCH] improved profile style --- .../graphic/WindowBackgroundDrawable.java | 39 ------------ .../fragment/AccountsDashboardFragment.kt | 2 +- .../graphic/WindowBackgroundDrawable.kt | 60 +++++++++++++++++++ .../src/main/res/values-w480dp/fractions.xml | 25 ++++++++ .../src/main/res/values-w600dp/fractions.xml | 25 ++++++++ .../fractions.xml | 0 twidere/src/main/res/values/fractions.xml | 19 ++++++ 7 files changed, 130 insertions(+), 40 deletions(-) delete mode 100644 twidere/src/main/java/org/mariotaku/twidere/graphic/WindowBackgroundDrawable.java create mode 100644 twidere/src/main/kotlin/org/mariotaku/twidere/graphic/WindowBackgroundDrawable.kt create mode 100644 twidere/src/main/res/values-w480dp/fractions.xml create mode 100644 twidere/src/main/res/values-w600dp/fractions.xml rename twidere/src/main/res/{values-land => values-w720dp}/fractions.xml (100%) diff --git a/twidere/src/main/java/org/mariotaku/twidere/graphic/WindowBackgroundDrawable.java b/twidere/src/main/java/org/mariotaku/twidere/graphic/WindowBackgroundDrawable.java deleted file mode 100644 index 2a63ba3a7..000000000 --- a/twidere/src/main/java/org/mariotaku/twidere/graphic/WindowBackgroundDrawable.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.mariotaku.twidere.graphic; - -import android.graphics.Canvas; -import android.graphics.ColorFilter; -import android.graphics.PixelFormat; -import android.graphics.drawable.Drawable; -import android.support.annotation.NonNull; - -/** - * Created by mariotaku on 16/3/30. - */ -public class WindowBackgroundDrawable extends Drawable { - - private final int color; - - public WindowBackgroundDrawable(int color) { - this.color = color; - } - - @Override - public void draw(@NonNull Canvas canvas) { - canvas.drawColor(color); - } - - @Override - public void setAlpha(int alpha) { - // No-op - } - - @Override - public void setColorFilter(ColorFilter colorFilter) { - // No-op - } - - @Override - public int getOpacity() { - return PixelFormat.TRANSLUCENT; - } -} diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsDashboardFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsDashboardFragment.kt index ec3f6e507..34921d809 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsDashboardFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/AccountsDashboardFragment.kt @@ -329,7 +329,7 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks, } internal fun updateAccountActions() { - val activity = activity as HomeActivity + val activity = activity as? HomeActivity ?: return val tabs = activity.tabs val account = accountsAdapter.selectedAccount ?: return var hasDmTab = false diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/graphic/WindowBackgroundDrawable.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/graphic/WindowBackgroundDrawable.kt new file mode 100644 index 000000000..10c61e5da --- /dev/null +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/graphic/WindowBackgroundDrawable.kt @@ -0,0 +1,60 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2017 Mariotaku Lee + * + * 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 . + */ + +package org.mariotaku.twidere.graphic + +import android.graphics.Canvas +import android.graphics.ColorFilter +import android.graphics.PixelFormat +import android.graphics.drawable.Drawable + +/** + * Created by mariotaku on 16/3/30. + */ +class WindowBackgroundDrawable(private val color: Int) : Drawable() { + + override fun draw(canvas: Canvas) { + canvas.drawColor(color) + } + + override fun setAlpha(alpha: Int) { + // No-op + } + + override fun setColorFilter(colorFilter: ColorFilter?) { + // No-op + } + + override fun getOpacity(): Int { + return PixelFormat.TRANSLUCENT + } + + override fun getConstantState(): Drawable.ConstantState { + return State(color) + } + + class State(private val color: Int) : ConstantState() { + + override fun newDrawable() = WindowBackgroundDrawable(color) + + override fun getChangingConfigurations() = 0 + + } + +} diff --git a/twidere/src/main/res/values-w480dp/fractions.xml b/twidere/src/main/res/values-w480dp/fractions.xml new file mode 100644 index 000000000..2bb6332b9 --- /dev/null +++ b/twidere/src/main/res/values-w480dp/fractions.xml @@ -0,0 +1,25 @@ + + + + + + 250%p + + \ No newline at end of file diff --git a/twidere/src/main/res/values-w600dp/fractions.xml b/twidere/src/main/res/values-w600dp/fractions.xml new file mode 100644 index 000000000..3eefca924 --- /dev/null +++ b/twidere/src/main/res/values-w600dp/fractions.xml @@ -0,0 +1,25 @@ + + + + + + 300%p + + \ No newline at end of file diff --git a/twidere/src/main/res/values-land/fractions.xml b/twidere/src/main/res/values-w720dp/fractions.xml similarity index 100% rename from twidere/src/main/res/values-land/fractions.xml rename to twidere/src/main/res/values-w720dp/fractions.xml diff --git a/twidere/src/main/res/values/fractions.xml b/twidere/src/main/res/values/fractions.xml index 1a381b02c..276e41c1d 100644 --- a/twidere/src/main/res/values/fractions.xml +++ b/twidere/src/main/res/values/fractions.xml @@ -1,4 +1,23 @@ + + 200%p