mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
First version of dark theme
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
android:backupAgent=".HabitsBackupAgent"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/main_activity_title"
|
||||
android:theme="@style/AppBaseTheme"
|
||||
android:theme="@style/AppBaseThemeDark"
|
||||
android:supportsRtl="true">
|
||||
|
||||
<meta-data
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package org.isoron.uhabits.helpers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -37,8 +36,7 @@ import java.util.GregorianCalendar;
|
||||
|
||||
public class ListHabitsHelper
|
||||
{
|
||||
public static final int INACTIVE_COLOR = Color.rgb(200, 200, 200);
|
||||
public static final int INACTIVE_CHECKMARK_COLOR = Color.rgb(230, 230, 230);
|
||||
private int inactiveColor;
|
||||
|
||||
private final Context context;
|
||||
private final HabitListLoader loader;
|
||||
@@ -49,6 +47,7 @@ public class ListHabitsHelper
|
||||
this.context = context;
|
||||
this.loader = loader;
|
||||
|
||||
inactiveColor = UIHelper.getStyledColor(context, R.attr.inactiveCheckmarkColor);
|
||||
fontawesome = Typeface.createFromAsset(context.getAssets(), "fontawesome-webfont.ttf");
|
||||
}
|
||||
|
||||
@@ -95,7 +94,7 @@ public class ListHabitsHelper
|
||||
public int getActiveColor(Habit habit)
|
||||
{
|
||||
int activeColor = habit.color;
|
||||
if(habit.isArchived()) activeColor = INACTIVE_COLOR;
|
||||
if(habit.isArchived()) activeColor = inactiveColor;
|
||||
|
||||
return activeColor;
|
||||
}
|
||||
@@ -129,12 +128,12 @@ public class ListHabitsHelper
|
||||
if (score < Score.HALF_STAR_CUTOFF)
|
||||
{
|
||||
tvStar.setText(context.getString(R.string.fa_star_o));
|
||||
tvStar.setTextColor(INACTIVE_COLOR);
|
||||
tvStar.setTextColor(inactiveColor);
|
||||
}
|
||||
else if (score < Score.FULL_STAR_CUTOFF)
|
||||
{
|
||||
tvStar.setText(context.getString(R.string.fa_star_half_o));
|
||||
tvStar.setTextColor(INACTIVE_COLOR);
|
||||
tvStar.setTextColor(inactiveColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -156,13 +155,13 @@ public class ListHabitsHelper
|
||||
|
||||
case 1:
|
||||
tvCheck.setText(R.string.fa_check);
|
||||
tvCheck.setTextColor(INACTIVE_CHECKMARK_COLOR);
|
||||
tvCheck.setTextColor(inactiveColor);
|
||||
tvCheck.setTag(R.string.toggle_key, 1);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
tvCheck.setText(R.string.fa_times);
|
||||
tvCheck.setTextColor(INACTIVE_CHECKMARK_COLOR);
|
||||
tvCheck.setTextColor(inactiveColor);
|
||||
tvCheck.setTag(R.string.toggle_key, 0);
|
||||
break;
|
||||
}
|
||||
@@ -175,7 +174,7 @@ public class ListHabitsHelper
|
||||
else
|
||||
{
|
||||
if (android.os.Build.VERSION.SDK_INT >= 21)
|
||||
view.setBackgroundResource(R.drawable.ripple_white);
|
||||
view.setBackgroundResource(R.drawable.ripple);
|
||||
else view.setBackgroundResource(R.drawable.card_background);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ package org.isoron.uhabits.helpers;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
import android.os.Debug;
|
||||
@@ -170,4 +171,14 @@ public abstract class UIHelper
|
||||
return context.getResources().getDisplayMetrics().widthPixels;
|
||||
}
|
||||
|
||||
public static int getStyledColor(Context context, int attrId)
|
||||
{
|
||||
int[] attrs = new int[]{ attrId };
|
||||
TypedArray ta = context.obtainStyledAttributes(attrs);
|
||||
int color = ta.getColor(0, 0);
|
||||
ta.recycle();
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import android.util.AttributeSet;
|
||||
import org.isoron.uhabits.R;
|
||||
import org.isoron.uhabits.helpers.ColorHelper;
|
||||
import org.isoron.uhabits.helpers.DateHelper;
|
||||
import org.isoron.uhabits.helpers.UIHelper;
|
||||
import org.isoron.uhabits.models.Habit;
|
||||
import org.isoron.uhabits.models.Score;
|
||||
|
||||
@@ -74,6 +75,7 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
|
||||
private boolean isBackgroundTransparent;
|
||||
private int bucketSize = 7;
|
||||
private int footerHeight;
|
||||
private int backgroundColor;
|
||||
|
||||
public HabitScoreView(Context context)
|
||||
{
|
||||
@@ -123,7 +125,8 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
|
||||
else
|
||||
{
|
||||
textColor = Color.argb(64, 0, 0, 0);
|
||||
dimmedTextColor = Color.argb(16, 0, 0, 0);
|
||||
dimmedTextColor = UIHelper.getStyledColor(getContext(), R.attr.fadedTextColor);
|
||||
backgroundColor = UIHelper.getStyledColor(getContext(), R.attr.cardBackgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,7 +348,7 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
|
||||
private void drawMarker(Canvas canvas, RectF rect)
|
||||
{
|
||||
rect.inset(baseSize * 0.15f, baseSize * 0.15f);
|
||||
setModeOrColor(pGraph, XFERMODE_CLEAR, Color.WHITE);
|
||||
setModeOrColor(pGraph, XFERMODE_CLEAR, backgroundColor);
|
||||
canvas.drawOval(rect, pGraph);
|
||||
|
||||
rect.inset(baseSize * 0.1f, baseSize * 0.1f);
|
||||
@@ -353,7 +356,7 @@ public class HabitScoreView extends ScrollableDataView implements HabitDataView
|
||||
canvas.drawOval(rect, pGraph);
|
||||
|
||||
rect.inset(baseSize * 0.1f, baseSize * 0.1f);
|
||||
setModeOrColor(pGraph, XFERMODE_CLEAR, Color.WHITE);
|
||||
setModeOrColor(pGraph, XFERMODE_CLEAR, backgroundColor);
|
||||
canvas.drawOval(rect, pGraph);
|
||||
|
||||
if(isBackgroundTransparent)
|
||||
|
||||
@@ -29,6 +29,7 @@ import android.view.View;
|
||||
|
||||
import org.isoron.uhabits.R;
|
||||
import org.isoron.uhabits.helpers.ColorHelper;
|
||||
import org.isoron.uhabits.helpers.UIHelper;
|
||||
import org.isoron.uhabits.models.Habit;
|
||||
import org.isoron.uhabits.models.Streak;
|
||||
|
||||
@@ -150,7 +151,7 @@ public class HabitStreakView extends View implements HabitDataView
|
||||
colors[2] = Color.argb(192, red, green, blue);
|
||||
colors[1] = Color.argb(96, red, green, blue);
|
||||
colors[0] = Color.argb(32, 0, 0, 0);
|
||||
textColor = Color.argb(64, 0, 0, 0);
|
||||
textColor = UIHelper.getStyledColor(getContext(), R.attr.fadedTextColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ public class RingView extends View
|
||||
private float maxDiameter;
|
||||
private float textSize;
|
||||
private int fadedTextColor;
|
||||
private int backgroundColor;
|
||||
|
||||
public RingView(Context context)
|
||||
{
|
||||
@@ -97,7 +98,8 @@ public class RingView extends View
|
||||
pRing.setColor(color);
|
||||
pRing.setTextAlign(Paint.Align.CENTER);
|
||||
|
||||
fadedTextColor = getResources().getColor(R.color.fadedTextColor);
|
||||
backgroundColor = UIHelper.getStyledColor(getContext(), R.attr.cardBackgroundColor);
|
||||
fadedTextColor = UIHelper.getStyledColor(getContext(), R.attr.fadedTextColor);
|
||||
textSize = getResources().getDimension(R.dimen.smallTextSize);
|
||||
|
||||
rect = new RectF();
|
||||
@@ -139,7 +141,7 @@ public class RingView extends View
|
||||
pRing.setColor(Color.argb(255, 230, 230, 230));
|
||||
canvas.drawArc(rect, 360 * percentage - 90 + 2, 360 * (1 - percentage) - 4, true, pRing);
|
||||
|
||||
pRing.setColor(Color.WHITE);
|
||||
pRing.setColor(backgroundColor);
|
||||
rect.inset(thickness, thickness);
|
||||
canvas.drawArc(rect, -90, 360, true, pRing);
|
||||
|
||||
|
||||
@@ -20,5 +20,5 @@
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="?android:colorControlHighlight">
|
||||
|
||||
<item android:drawable="@color/white" />
|
||||
<item android:drawable="?attr/cardBackgroundColor" />
|
||||
</ripple>
|
||||
@@ -21,7 +21,7 @@
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@color/windowBackground"
|
||||
android:background="?windowBackgroundColor"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -31,10 +31,10 @@
|
||||
dslv:sort_enabled="true"
|
||||
dslv:track_drag_sort="false"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@color/windowBackground"
|
||||
android:background="?windowBackgroundColor"
|
||||
android:paddingTop="@dimen/checkmarkHeight"
|
||||
android:layout_height="match_parent"
|
||||
android:divider="@color/windowBackground"
|
||||
android:divider="?windowBackgroundColor"
|
||||
android:dividerHeight="1dp"/>
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:background="@color/transparent"
|
||||
android:textColor="@color/fadedTextColor"
|
||||
android:textColor="?fadedTextColor"
|
||||
android:textAllCaps="true"
|
||||
android:textStyle="bold"
|
||||
android:textSize="10sp"/>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/windowBackground"
|
||||
android:background="?windowBackgroundColor"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -20,15 +20,42 @@
|
||||
<resources>
|
||||
|
||||
<style name="AppBaseTheme" parent="android:Theme.Material.Light.DarkActionBar">
|
||||
<item name="android:textColor">#606060</item>
|
||||
<item name="android:colorPrimary">@color/primary</item>
|
||||
<item name="android:colorPrimaryDark">@color/primary_darker</item>
|
||||
<item name="android:dialogTheme">@style/MyDialogStyle</item>
|
||||
<item name="android:alertDialogTheme">@style/MyDialogStyle</item>
|
||||
<item name="android:windowContentTransitions">true</item>
|
||||
<item name="android:windowAllowEnterTransitionOverlap">true</item>
|
||||
<item name="android:windowAllowReturnTransitionOverlap">true</item>
|
||||
<item name="android:spinnerItemStyle">@style/dialogFormSmallText</item>
|
||||
|
||||
<item name="android:colorPrimary">@color/blue_grey_800</item>
|
||||
<item name="android:colorPrimaryDark">@color/blue_grey_900</item>
|
||||
<item name="cardBackgroundColor">@color/white</item>
|
||||
<item name="windowBackgroundColor">@color/grey_200</item>
|
||||
<item name="headerBackgroundColor">@color/grey_200</item>
|
||||
|
||||
<item name="android:textColor">#606060</item>
|
||||
<item name="fadedTextColor">@color/grey_600</item>
|
||||
<item name="inactiveCheckmarkColor">@color/grey_600</item>
|
||||
<item name="secondaryTextColor">@color/grey_800</item>
|
||||
</style>
|
||||
|
||||
<style name="AppBaseThemeDark" parent="android:Theme.Material">
|
||||
<item name="android:dialogTheme">@style/MyDialogStyleDark</item>
|
||||
<item name="android:alertDialogTheme">@style/MyDialogStyleDark</item>
|
||||
<item name="android:windowContentTransitions">true</item>
|
||||
<item name="android:windowAllowEnterTransitionOverlap">true</item>
|
||||
<item name="android:windowAllowReturnTransitionOverlap">true</item>
|
||||
|
||||
<item name="android:colorPrimary">@color/grey_900</item>
|
||||
<item name="android:colorPrimaryDark">@color/black</item>
|
||||
<item name="cardBackgroundColor">@color/grey_800</item>
|
||||
<item name="windowBackgroundColor">@color/grey_850</item>
|
||||
<item name="headerBackgroundColor">@color/grey_875</item>
|
||||
|
||||
<item name="android:textColor">@color/grey_50</item>
|
||||
<item name="fadedTextColor">@color/grey_500</item>
|
||||
<item name="inactiveCheckmarkColor">@color/grey_700</item>
|
||||
<item name="secondaryTextColor">@color/grey_100</item>
|
||||
</style>
|
||||
|
||||
<style name="MyDialogStyle" parent="android:Theme.Material.Light.Dialog">
|
||||
@@ -36,8 +63,14 @@
|
||||
<item name="android:spinnerDropDownItemStyle">@style/dialogFormSpinnerDropDown</item>
|
||||
</style>
|
||||
|
||||
<style name="MyDialogStyleDark" parent="android:Theme.Material.Dialog">
|
||||
<item name="android:spinnerItemStyle">@style/dialogFormText</item>
|
||||
<item name="android:spinnerDropDownItemStyle">@style/dialogFormSpinnerDropDown</item>
|
||||
</style>
|
||||
|
||||
<style name="Card" parent="CardCommon">
|
||||
<item name="android:elevation">1dp</item>
|
||||
<item name="android:background">?attr/cardBackgroundColor</item>
|
||||
</style>
|
||||
|
||||
<style name="About.Item.Clickable" parent="About.Item">
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<resources>
|
||||
|
||||
<style name="ListHabits.Header">
|
||||
<item name="android:background">#f0f0f0</item>
|
||||
<item name="android:background">?headerBackgroundColor</item>
|
||||
<item name="android:elevation">2dp</item>
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
|
||||
28
app/src/main/res/values/attrs.xml
Normal file
28
app/src/main/res/values/attrs.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2016 Álinson Santos Xavier <isoron@gmail.com>
|
||||
~
|
||||
~ This file is part of Loop Habit Tracker.
|
||||
~
|
||||
~ Loop Habit Tracker 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.
|
||||
~
|
||||
~ Loop Habit Tracker 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/>.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<attr name="windowBackgroundColor" format="reference"/>
|
||||
<attr name="cardBackgroundColor" format="reference"/>
|
||||
<attr name="fadedTextColor" format="reference"/>
|
||||
<attr name="headerBackgroundColor" format="reference"/>
|
||||
<attr name="secondaryTextColor" format="reference"/>
|
||||
<attr name="inactiveCheckmarkColor" format="reference"/>
|
||||
</resources>
|
||||
@@ -15,15 +15,6 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
|
||||
<color name="primary">#37474f</color>
|
||||
<color name="primary_darker">#263238</color>
|
||||
<color name="windowBackground">#e6e6e6</color>
|
||||
<color name="primaryTextColor">@color/grey_900</color>
|
||||
<color name="secondaryTextColor">@color/grey_800</color>
|
||||
<color name="fadedTextColor">@color/grey_600</color>
|
||||
|
||||
<color name="white">#ffffff</color>
|
||||
|
||||
<!-- Time and Date picker -->
|
||||
<color name="circle_background">#f2f2f2</color>
|
||||
@@ -151,8 +142,8 @@
|
||||
<!--<color name="blue_grey_500">#607D8B</color>-->
|
||||
<!--<color name="blue_grey_600">#546E7A</color>-->
|
||||
<!--<color name="blue_grey_700">#455A64</color>-->
|
||||
<!--<color name="blue_grey_800">#37474F</color>-->
|
||||
<!--<color name="blue_grey_900">#263238</color>-->
|
||||
<color name="blue_grey_800">#37474F</color>
|
||||
<color name="blue_grey_900">#263238</color>
|
||||
|
||||
<!--<color name="pink_50">#FCE4EC</color>-->
|
||||
<!--<color name="pink_100">#F8BBD0</color>-->
|
||||
@@ -324,5 +315,10 @@
|
||||
<color name="grey_600">#757575</color>
|
||||
<color name="grey_700">#616161</color>
|
||||
<color name="grey_800">#424242</color>
|
||||
<color name="grey_850">#303030</color>
|
||||
<color name="grey_875">#282828</color>
|
||||
<color name="grey_900">#212121</color>
|
||||
|
||||
<color name="white">#ffffff</color>
|
||||
<color name="black">#000000</color>
|
||||
</resources>
|
||||
@@ -41,7 +41,7 @@
|
||||
<style name="CardList">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:background">@color/windowBackground</item>
|
||||
<item name="android:background">?windowBackgroundColor</item>
|
||||
<item name="android:orientation">vertical</item>
|
||||
</style>
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:layout_marginLeft">8dp</item>
|
||||
<item name="android:layout_marginRight">8dp</item>
|
||||
<item name="android:textColor">@color/fadedTextColor</item>
|
||||
<item name="android:textColor">?fadedTextColor</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -45,19 +45,19 @@
|
||||
|
||||
<style name="dialogFormText">
|
||||
<item name="android:textSize">@dimen/regularTextSize</item>
|
||||
<item name="android:textColor">@color/secondaryTextColor</item>
|
||||
<item name="android:textColor">?secondaryTextColor</item>
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
</style>
|
||||
|
||||
<style name="dialogFormSmallText">
|
||||
<item name="android:textSize">@dimen/smallTextSize</item>
|
||||
<item name="android:textColor">@color/fadedTextColor</item>
|
||||
<item name="android:textColor">?fadedTextColor</item>
|
||||
</style>
|
||||
|
||||
<style name="dialogFormSpinnerDropDown" parent="dialogFormText">
|
||||
<item name="android:padding">12dp</item>
|
||||
<item name="android:textColor">@color/secondaryTextColor</item>
|
||||
<item name="android:textColor">?secondaryTextColor</item>
|
||||
</style>
|
||||
|
||||
<style name="dialogFormInput" parent="dialogFormText">
|
||||
@@ -74,7 +74,7 @@
|
||||
<item name="android:minWidth">100dp</item>
|
||||
<item name="android:gravity">left</item>
|
||||
<item name="android:paddingLeft">6dp</item>
|
||||
<item name="android:textColor">@color/fadedTextColor</item>
|
||||
<item name="android:textColor">?fadedTextColor</item>
|
||||
</style>
|
||||
|
||||
<style name="dialogFormSpinner" parent="android:Widget.DeviceDefault.Light.Spinner">
|
||||
@@ -83,7 +83,7 @@
|
||||
<item name="android:paddingLeft">12dp</item>
|
||||
<item name="android:textSize">@dimen/regularTextSize</item>
|
||||
<item name="android:minWidth">400dp</item>
|
||||
<item name="android:textColor">@color/secondaryTextColor</item>
|
||||
<item name="android:textColor">?secondaryTextColor</item>
|
||||
</style>
|
||||
|
||||
<style name="dialogFormRow">
|
||||
|
||||
Reference in New Issue
Block a user