Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dark theme #880

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/src/main/java/free/rm/skytube/app/SkyTubeApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ public static String getStr(int stringResId) {


/**
* Given a string array resource ID, it returns an array of strings.
* Given a string array.xml resource ID, it returns an array.xml of strings.
*
* @param stringArrayResId String array resource ID (e.g. R.string.my_array_string)
* @param stringArrayResId String array.xml resource ID (e.g. R.string.my_array_string)
* @return Array of String.
*/
public static String[] getStringArray(int stringArrayResId) {
Expand All @@ -122,9 +122,9 @@ public static String[] getStringArray(int stringArrayResId) {


/**
* Given a string array resource ID, it returns an list of strings.
* Given a string array.xml resource ID, it returns an list of strings.
*
* @param stringArrayResId String array resource ID (e.g. R.string.my_array_string)
* @param stringArrayResId String array.xml resource ID (e.g. R.string.my_array_string)
* @return List of String.
*/
public static List<String> getStringArrayAsList(int stringArrayResId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public SkyTubeMaterialDialog(@NonNull Context context) {
super(context);

titleColorRes(R.color.dialog_title);
backgroundColorRes(R.color.dialog_backgound);
backgroundColorRes(R.color.dialog_background);
contentColorRes(R.color.dialog_content_text);
positiveColorRes(R.color.dialog_positive_text);
negativeColorRes(R.color.dialog_negative_text);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package free.rm.skytube.gui.fragments;

import android.os.Build;
import android.os.Bundle;

import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.os.BuildCompat;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;

import free.rm.skytube.R;

public class ThemePreferenceFragment extends PreferenceFragmentCompat {

@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.preference_theme);

Preference preference = findPreference(getString(R.string.pref_key_night));
preference.setOnPreferenceChangeListener((preference1, newValue) -> {

if (newValue.equals(getString(R.string.pref_night_on))) {
updateTheme(AppCompatDelegate.MODE_NIGHT_YES);
}
else if (newValue.equals(getString(R.string.pref_night_off))) {
updateTheme(AppCompatDelegate.MODE_NIGHT_NO);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY);
}

return true;
});
}

private boolean updateTheme(int nightMode) {

AppCompatDelegate.setDefaultNightMode(nightMode);
requireActivity().recreate();
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private List<MultiSelectListPreferenceItem> getLanguagesList() {
List<MultiSelectListPreferenceItem> languageAvailableList = new ArrayList<>();

if (BuildConfig.DEBUG && (languagesNames.length != languagesIsoCodes.length)) {
throw new AssertionError("languages names array is NOT EQUAL to languages ISO codes array.");
throw new AssertionError("languages names array.xml is NOT EQUAL to languages ISO codes array.xml.");
}

for (int i = 0; i < languagesNames.length; i++) {
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/res/drawable/ic_baseline_nights_stay_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/black"
android:pathData="M11.1,12.08C8.77,7.57 10.6,3.6 11.63,2.01C6.27,2.2 1.98,6.59 1.98,12c0,0.14 0.02,0.28 0.02,0.42C2.62,12.15 3.29,12 4,12c1.66,0 3.18,0.83 4.1,2.15C9.77,14.63 11,16.17 11,18c0,1.52 -0.87,2.83 -2.12,3.51c0.98,0.32 2.03,0.5 3.11,0.5c3.5,0 6.58,-1.8 8.37,-4.52C18,17.72 13.38,16.52 11.1,12.08z"/>
<path
android:fillColor="@android:color/black"
android:pathData="M7,16l-0.18,0C6.4,14.84 5.3,14 4,14c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.62,0 2.49,0 3,0c1.1,0 2,-0.9 2,-2C9,16.9 8.1,16 7,16z"/>
</vector>
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_pref_theme.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="#515B60"
android:pathData="M20,8.69V4h-4.69L12,0.69 8.69,4H4v4.69L0.69,12 4,15.31V20h4.69L12,23.31 15.31,20H20v-4.69L23.31,12 20,8.69zM12,18c-0.89,0 -1.74,-0.2 -2.5,-0.55C11.56,16.5 13,14.42 13,12s-1.44,-4.5 -3.5,-5.45C10.26,6.2 11.11,6 12,6c3.31,0 6,2.69 6,6s-2.69,6 -6,6z"/>
</vector>
9 changes: 5 additions & 4 deletions app/src/main/res/layout/fragment_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,25 @@
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
android:theme="@style/ThemeOverlay.AppCompat.DayNight.ActionBar">

<!-- TOOLBAR / ACTIONBAR -->
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:theme="@style/ThemeOverlay.AppCompat.DayNight"
app:layout_scrollFlags="scroll|enterAlways" />

<!-- TABS -->
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:layout_gravity="center_horizontal"
app:tabMode="scrollable"/>
android:background="?attr/colorPrimary"
app:tabMode="scrollable"
app:tabSelectedTextColor="@color/colorPrimaryDark" />

</com.google.android.material.appbar.AppBarLayout>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/multi_select_list_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/dialog_backgound"
android:background="@color/dialog_background"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingStart="10dp"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/subs_youtube_import_dialog_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/dialog_backgound"
android:background="@color/dialog_background"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/dialog_backgound"
android:background="@color/dialog_background"
android:orientation="horizontal">

<Button
Expand Down
87 changes: 87 additions & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#424c54</color>
<color name="colorPrimaryDark">#21272B</color>
<color name="colorAccent">#26A69A</color>
<color name="colorText">#ffffff</color>

<color name="skytube_theme_colour">#ff6600</color>

<!--
Material Dialog Colors
-->
<color name="dialog_title">#000</color>
<color name="dialog_background">#FFF</color>
<color name="dialog_content_text">#000</color>
<color name="dialog_positive_text">@color/colorAccent</color>
<color name="dialog_negative_text">@color/colorAccent</color>
<color name="dialog_neutral_text">@color/colorAccent</color>
<color name="dialog_row_0">#F0F0F0</color>
<color name="dialog_row_1">@color/dialog_background</color>


<!--
Subs Drawer Colours
-->
<color name="subs_drawer_background">#CC21272B</color>
<drawable name="sub_channel_pressed">@color/colorAccent</drawable>
<drawable name="sub_channel">@android:color/transparent</drawable>
<color name="subs_text">#FFF</color>

<drawable name="subscribe_button">@color/skytube_theme_colour</drawable>
<drawable name="subscribe_button_pressed">#ff8e44</drawable>


<!--
Video (Grid) Cells
-->
<color name="video_cell_background">#94a3b1</color>
<color name="video_cell_text_main">#ffffff</color>
<color name="video_cell_text_details">#ffffff</color>
<color name="video_cell_highlighted_background">@color/colorPrimaryDark</color>

<color name="grid_view_background">@color/colorPrimaryDark</color>
<color name="popup_menu">#cfcfcf</color> <!-- Identical to @color/background_material_dark -->


<!--
Video Player Tutorial
-->
<color name="tutorial_background">@color/colorPrimary</color>
<color name="tutorial_swipe_area">#277AA2</color>


<!--
Video Player Colours
-->
<!-- Actionbar background colour ~~ which is the same as com.android.internal.R.layout.media_controller
(used to be #BB000000) -->
<color name="video_player_hud">#CC000000</color>
<color name="video_player_drawer_background">@color/video_player_hud</color>
<color name="video_player_drawer_text">#b3b3b3</color>

<color name="video_desc_like_bar">@color/skytube_theme_colour</color>

<!-- Comments -->
<color name="comment_background">@color/video_player_hud</color>
<color name="comment_text">#b3b3b3</color>

<!-- Player v2 -->
<color name="video_player_v2_hud">#7A000000</color>
<color name="video_player_v2_seek_bar">@color/colorAccent</color>


<!--
Channel Browser
-->
<color name="channel_subs">@color/video_cell_text_main</color>
<color name="channel_about">@color/video_cell_text_main</color>
<color name="channel_subscribers_bkg">#66000000</color>


<!--
Subscriptions Feed
-->
<color name="feed_message_text">#FFF</color>

</resources>
13 changes: 13 additions & 0 deletions app/src/main/res/values/array.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="night_mode">
<item>@string/night_mode_auto</item>
<item>@string/night_mode_on</item>
<item>@string/night_mode_off</item>
</string-array>
<string-array name="night_mode_value">
<item>@string/pref_night_auto</item>
<item>@string/pref_night_on</item>
<item>@string/pref_night_off</item>
</string-array>
</resources>
37 changes: 19 additions & 18 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#263238</color>
<color name="colorPrimaryDark">#21272B</color>
<color name="colorPrimary">#ffffff</color>
<color name="colorPrimaryDark">#6d7d8b</color>
<color name="colorAccent">#26A69A</color>
<color name="colorText">#6d7d8b</color>

<color name="skytube_theme_colour">#ff6600</color>

<!--
Material Dialog Colors
-->
<color name="dialog_title">#000</color>
<color name="dialog_backgound">#FFF</color>
<color name="dialog_content_text">#000</color>
<color name="dialog_title">#fff</color>
<color name="dialog_background">#000</color>
<color name="dialog_content_text">#fff</color>
<color name="dialog_positive_text">@color/colorAccent</color>
<color name="dialog_negative_text">@color/colorAccent</color>
<color name="dialog_neutral_text">@color/colorAccent</color>
<color name="dialog_row_0">#F0F0F0</color>
<color name="dialog_row_1">@color/dialog_backgound</color>
<color name="dialog_row_0">#0f0f0f</color>
<color name="dialog_row_1">@color/dialog_background</color>


<!--
Subs Drawer Colours
-->
<color name="subs_drawer_background">#CC21272B</color>
<color name="subs_drawer_background">#CC9DABB4</color>
<drawable name="sub_channel_pressed">@color/colorAccent</drawable>
<drawable name="sub_channel">@android:color/transparent</drawable>
<color name="subs_text">#FFF</color>
<color name="subs_text">#000</color>

<drawable name="subscribe_button">@color/skytube_theme_colour</drawable>
<drawable name="subscribe_button_pressed">#ff8e44</drawable>
Expand All @@ -34,13 +35,13 @@
<!--
Video (Grid) Cells
-->
<color name="video_cell_background">#111517</color>
<color name="video_cell_text_main">#F5F5F5</color>
<color name="video_cell_text_details">#808080</color>
<color name="video_cell_background">#94a3b1</color>
<color name="video_cell_text_main">#ffffff</color>
<color name="video_cell_text_details">#ffffff</color>
<color name="video_cell_highlighted_background">@color/colorPrimaryDark</color>

<color name="grid_view_background">@color/colorPrimaryDark</color>
<color name="popup_menu">#FF303030</color> <!-- Identical to @color/background_material_dark -->
<color name="popup_menu">#cfcfcf</color> <!-- Identical to @color/background_material_dark -->


<!--
Expand All @@ -55,9 +56,9 @@
-->
<!-- Actionbar background colour ~~ which is the same as com.android.internal.R.layout.media_controller
(used to be #BB000000) -->
<color name="video_player_hud">#CC000000</color>
<color name="video_player_hud">#CCffffff</color>
<color name="video_player_drawer_background">@color/video_player_hud</color>
<color name="video_player_drawer_text">#b3b3b3</color>
<color name="video_player_drawer_text">#4c4c4c</color>

<color name="video_desc_like_bar">@color/skytube_theme_colour</color>

Expand All @@ -66,7 +67,7 @@
<color name="comment_text">#b3b3b3</color>

<!-- Player v2 -->
<color name="video_player_v2_hud">#7A000000</color>
<color name="video_player_v2_hud">#7Affffff</color>
<color name="video_player_v2_seek_bar">@color/colorAccent</color>


Expand All @@ -75,12 +76,12 @@
-->
<color name="channel_subs">@color/video_cell_text_main</color>
<color name="channel_about">@color/video_cell_text_main</color>
<color name="channel_subscribers_bkg">#66000000</color>
<color name="channel_subscribers_bkg">#66ffffff</color>


<!--
Subscriptions Feed
-->
<color name="feed_message_text">#FFF</color>
<color name="feed_message_text">#000</color>

</resources>
10 changes: 10 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,14 @@
<string name="yes">Yes</string>
<string name="no">No</string>
<string name="search_channel">Search channel</string>
<string name="pref_key_night" translatable="false">key_night_mode</string>
<string name="pref_night_title">Night mode</string>
<string name="pref_night_summary">Select a dark or light theme.</string>
<string name="pref_night_dialog">Set Night mode</string>
<string name="pref_night_auto" translatable="false">auto</string>
<string name="pref_night_on" translatable="false">on</string>
<string name="pref_night_off" translatable="false">off</string>
<string name="night_mode_auto">Automatic</string>
<string name="night_mode_on">Night mode</string>
<string name="night_mode_off">Day mode</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<string name="pref_summary_autocast">Select a Chromecast device to use when using other apps to open videos in SkyTube.</string>
<string name="pref_network_downloads_category">Network and Downloads</string>
<string name="pref_about_category">About</string>
<string name="pref_night_theme">Night Theme</string>
<string name="pref_title_website">Website</string>
<string name="pref_key_website" translatable="false">pref_website</string>
<string name="pref_title_credits">Credits</string>
Expand Down
Loading