Commit 369ad9dc authored by Geoffrey Métais's avatar Geoffrey Métais

DayNight mode

parent ed8acdea
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.VLC"
parent="Theme.VLC.Black" />
</resources>
\ No newline at end of file
......@@ -264,6 +264,8 @@
<string name="enable_black_theme">Enable the black theme</string>
<string name="enable_black_theme_summary">Change the interface colours for better comfort in low light environments.</string>
<string name="subtitle_text_encoding">Subtitle text encoding</string>
<string name="daynight_title">DayNight mode</string>
<string name="daynight_summary">Automatically switch to night mode at appropriate time</string>
<string name="extra_prefs_category">Extra settings</string>
......
......@@ -8,7 +8,15 @@
android:defaultValue="false"
android:key="enable_black_theme"
android:summary="@string/enable_black_theme_summary"
android:title="@string/enable_black_theme" />
android:title="@string/enable_black_theme"
android:disableDependentsState="true" />
<android.support.v7.preference.SwitchPreferenceCompat
android:defaultValue="false"
android:key="daynight"
android:dependency="enable_black_theme"
android:summary="@string/daynight_summary"
android:title="@string/daynight_title" />
<CheckBoxPreference
android:key="tv_ui"
......
......@@ -36,6 +36,7 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
......@@ -55,7 +56,6 @@ import org.videolan.vlc.interfaces.IRefreshable;
import org.videolan.vlc.media.MediaLibrary;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.Util;
import org.videolan.vlc.util.WeakHandler;
public class AudioPlayerContainerActivity extends AppCompatActivity implements PlaybackService.Client.Callback {
......@@ -63,6 +63,10 @@ public class AudioPlayerContainerActivity extends AppCompatActivity implements P
public static final String TAG = "VLC/AudioPlayerContainerActivity";
public static final String ACTION_SHOW_PLAYER = Strings.buildPkgString("gui.ShowPlayer");
static {
AppCompatDelegate.setDefaultNightMode(PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext()).getBoolean("daynight", false) ? AppCompatDelegate.MODE_NIGHT_AUTO : AppCompatDelegate.MODE_NIGHT_NO);
}
protected static final String ID_VIDEO = "video";
protected static final String ID_AUDIO = "audio";
protected static final String ID_NETWORK = "network";
......
......@@ -25,10 +25,13 @@ package org.videolan.vlc.gui.preferences;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.preference.Preference;
import android.support.v7.preference.SwitchPreferenceCompat;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.helpers.UiTools;
public class PreferencesUi extends BasePreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
......@@ -73,6 +76,9 @@ public class PreferencesUi extends BasePreferenceFragment implements SharedPrefe
case "enable_black_theme":
((PreferencesActivity) getActivity()).exitAndRescan();
return true;
case "daynight":
AppCompatDelegate.setDefaultNightMode(((SwitchPreferenceCompat)preference).isChecked() ? AppCompatDelegate.MODE_NIGHT_AUTO : AppCompatDelegate.MODE_NIGHT_NO);
return true;
}
return super.onPreferenceTreeClick(preference);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment