Skip to content

Commit

Permalink
ADD: Dark theme (auto)
Browse files Browse the repository at this point in the history
  • Loading branch information
oasisfeng committed Apr 29, 2020
1 parent f206a00 commit 5a5e11c
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 24 deletions.
4 changes: 2 additions & 2 deletions mobile/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@

<activity android:name="com.oasisfeng.island.settings.SettingsActivity"
android:label="@string/settings_title"
android:theme="@android:style/Theme.Material.Settings"
android:theme="@style/AppTheme.Settings"
android:parentActivityName="com.oasisfeng.island.MainActivity" />

<activity android:name="com.oasisfeng.island.settings.IslandSettingsActivity"
android:label="@string/label_activity_island_settings"
android:theme="@android:style/Theme.Material.Settings"
android:theme="@style/AppTheme.Settings"
android:enabled="false"> <!-- Enabled explicitly for managed profiles during Island setup -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
2 changes: 1 addition & 1 deletion mobile/src/main/res/drawable/ic_info_black_24dp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:fillColor="@color/action_icon"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zm1,15h-2v-6h2v6zm0,-8h-2V7h2v2z" />
</vector>
2 changes: 1 addition & 1 deletion mobile/src/main/res/drawable/ic_launch_24dp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
android:viewportHeight="24.0"
android:autoMirrored="true">
<path
android:fillColor="@color/primary_dark"
android:fillColor="@color/side_control"
android:pathData="M19,19H5V5h7V3H5c-1.11,0 -2,0.9 -2,2v14c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2v-7h-2v7zM14,3v2h3.59l-9.83,9.83 1.41,1.41L19,6.41V10h2V3h-7z"/>
</vector>
2 changes: 1 addition & 1 deletion mobile/src/main/res/drawable/ic_settings_black_24dp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:fillColor="@color/action_icon"
android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
</vector>
9 changes: 5 additions & 4 deletions mobile/src/main/res/layout/app_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
android:background="@color/background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_small"
android:layout_marginBottom="@dimen/margin_small"
android:layout_marginStart="@dimen/margin_medium"
android:layout_marginEnd="@dimen/margin_medium"
android:paddingTop="@dimen/margin_small"
android:paddingBottom="@dimen/margin_small"
android:paddingStart="@dimen/margin_medium"
android:paddingEnd="@dimen/margin_medium"
app:chipSpacing="@dimen/margin_medium"
bind:shown="@{apps.mChipsVisible &amp;&amp; ! featured.visible}">

Expand All @@ -50,6 +50,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:chipStrokeColor="@color/accent"
app:chipIconTint="@color/accent"
app:chipStrokeWidth="2dp"
app:checkedIconVisible="false"
app:chipBackgroundColor="@color/chip_background_color"
Expand Down
2 changes: 1 addition & 1 deletion mobile/src/main/res/layout/featured_entry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
android:layout_marginBottom="0dp"
android:elevation="@dimen/elevation_card_resting"
app:contentPadding="@dimen/card_content_padding"
app:cardBackgroundColor="@{safeUnbox(vm.dismissed) ? @color/background : @color/background_highlight}">
app:cardBackgroundColor="@{safeUnbox(vm.dismissed) ? @color/background : @color/card_background}">

<RelativeLayout
android:layout_width="match_parent"
Expand Down
13 changes: 13 additions & 0 deletions mobile/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Semantic colors -->
<color name="background">#121212</color>
<color name="background_highlight">#2C2C2C</color> <!-- background + 16% white -->
<color name="card_background">#2C2C2C</color>
<color name="card_attention">#635732</color>
<color name="card_button">#259B24</color>
<!-- Specific colors -->
<color name="state_alive">#DD6F00</color>
<color name="state_frozen">#536dfe</color> <!-- Indigo A400 -->
<color name="side_control">#536dfe</color>
</resources>
4 changes: 3 additions & 1 deletion mobile/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
<!-- Semantic colors -->
<color name="background">#F3F3F3</color>
<color name="background_highlight">@android:color/white</color>
<color name="card_background">@android:color/white</color>
<color name="card_attention">#FFFFE082</color>
<color name="card_button">#259B24</color>
<!-- Specific colors -->
<color name="state_alive">#FF6D00</color>
<color name="state_alive">#FF8F00</color>
<color name="state_frozen">@color/primary_dark</color>
<color name="side_control">@color/primary_dark</color>
</resources>
18 changes: 8 additions & 10 deletions mobile/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,26 @@
<!-- Duplicate entries without "android" namespace are for AppCompat,
to be compatible with Android Design Support Library -->

<style name="AppTheme.NoActionBar" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:colorPrimary">@color/primary</item>
<style name="AppTheme.NoActionBar" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="android:colorAccent">@color/accent</item>
<item name="colorAccent">@color/accent</item>
<item name="android:colorControlHighlight">@color/control_highlight</item>
<item name="colorControlHighlight">@color/control_highlight</item>

<item name="materialAlertDialogTheme">@style/Theme.MaterialComponents.DayNight.Dialog.Alert</item>
<item name="android:navigationBarColor">@color/primary_dark</item>
</style>

<style name="AppTheme.Dark" parent="android:Theme.Material">
<item name="android:colorPrimary">@color/primary</item>
<style name="AppTheme.Dark" parent="Theme.MaterialComponents">
<item name="colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="android:colorAccent">@color/accent</item>
<item name="colorAccent">@color/accent</item>
</style>

<style name="AppTheme.Settings" parent="Theme.MaterialComponents.DayNight.Bridge"> <!-- These attributes restore the action-bar -->
<item name="android:windowActionBar">true</item>
<item name="android:windowNoTitle">false</item>
</style>

<style name="AppThemeOverlay.Dark.Popup" parent="android:ThemeOverlay.Material.Dark">
<item name="android:colorBackground">?android:attr/colorPrimaryDark</item>
</style>
Expand Down
2 changes: 1 addition & 1 deletion shared/src/main/res/drawable/ic_landscape_black_24dp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:fillColor="@color/action_icon"
android:pathData="M14,6l-3.75,5 2.85,3.8 -1.6,1.2C9.81,13.75 7,10 7,10l-6,8h22L14,6z"/>
</vector>
9 changes: 9 additions & 0 deletions shared/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Global style colors -->
<color name="primary">#303F9F</color>
<color name="primary_dark">#1a237e</color>
<color name="accent">#c67100</color>

<color name="action_icon">@android:color/white</color>
</resources>
5 changes: 3 additions & 2 deletions shared/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- Global style colors -->
<color name="primary">#3F51B5</color>
<color name="primary_dark">#303F9F</color>
<color name="accent">#FFAB40</color>
<color name="control_highlight">#423F51B5</color>
<color name="accent">#FFA000</color>

<color name="action_icon">@android:color/black</color>
</resources>

0 comments on commit 5a5e11c

Please sign in to comment.