Added dark theme

This commit is contained in:
59436419 2016-12-30 00:49:39 +05:30
parent e4aa69b8d3
commit 68e80e6054
14 changed files with 75 additions and 14 deletions

View File

@ -48,6 +48,7 @@ public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
// init crashreport
try {
final ACRAConfiguration acraConfig = new ConfigurationBuilder(this)

View File

@ -4,6 +4,7 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
@ -31,6 +32,7 @@ import org.schabi.newpipe.info_list.InfoListAdapter;
import org.schabi.newpipe.report.ErrorActivity;
import java.io.IOException;
import java.util.Objects;
/**
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
@ -71,6 +73,10 @@ public class ChannelActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
if (Objects.equals(PreferenceManager.getDefaultSharedPreferences(this)
.getString("theme", "1"), "0")) {
setTheme(R.style.DarkTheme_NoActionBar);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_channel);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
@ -128,7 +134,7 @@ public class ChannelActivity extends AppCompatActivity {
CollapsingToolbarLayout ctl = (CollapsingToolbarLayout) findViewById(R.id.channel_toolbar_layout);
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
ImageView channelBanner = (ImageView) findViewById(R.id.channel_banner_image);
FloatingActionButton feedButton = (FloatingActionButton) findViewById(R.id.channel_rss_fab);
final FloatingActionButton feedButton = (FloatingActionButton) findViewById(R.id.channel_rss_fab);
ImageView avatarView = (ImageView) findViewById(R.id.channel_avatar_view);
ImageView haloView = (ImageView) findViewById(R.id.channel_avatar_halo);

View File

@ -1,7 +1,9 @@
package org.schabi.newpipe;
import android.app.Activity;
import android.content.Intent;
import android.media.AudioManager;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.NavUtils;
import android.support.v7.app.AppCompatActivity;
@ -9,9 +11,14 @@ import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.Toast;
import org.schabi.newpipe.settings.NewPipeSettings;
import org.schabi.newpipe.settings.SettingsActivity;
import java.util.Objects;
import java.util.prefs.Preferences;
/**
* Created by Christian Schabesberger on 02.08.16.
*
@ -32,7 +39,7 @@ import org.schabi.newpipe.settings.SettingsActivity;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/
public class MainActivity extends AppCompatActivity {
public class MainActivity extends Themer {
private Fragment mainFragment = null;

View File

@ -14,6 +14,7 @@ import android.widget.Toast;
import org.schabi.newpipe.App;
import org.schabi.newpipe.MainActivity;
import org.schabi.newpipe.R;
import org.schabi.newpipe.Themer;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
@ -39,7 +40,7 @@ import java.util.HashSet;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/
public class VideoItemDetailActivity extends AppCompatActivity {
public class VideoItemDetailActivity extends Themer {
/**
* Removes invisible separators (\p{Z}) and punctuation characters including

View File

@ -13,7 +13,6 @@ import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.v4.app.NavUtils;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
@ -28,8 +27,9 @@ import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.R;
import org.schabi.newpipe.Themer;
import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.settings.SettingsActivity;
import java.io.File;
@ -42,7 +42,7 @@ import us.shandian.giga.ui.fragment.MissionsFragment;
import us.shandian.giga.util.CrashHandler;
import us.shandian.giga.util.Utility;
public class DownloadActivity extends AppCompatActivity implements AdapterView.OnItemClickListener{
public class DownloadActivity extends Themer implements AdapterView.OnItemClickListener{
public static final String INTENT_DOWNLOAD = "us.shandian.giga.intent.DOWNLOAD";

View File

@ -36,6 +36,7 @@ public class InfoItemHolder extends RecyclerView.ViewHolder {
itemDurationView,
itemUploadDateView,
itemViewCountView;
public Button itemButton;
public InfoItemHolder(View v) {
@ -48,4 +49,5 @@ public class InfoItemHolder extends RecyclerView.ViewHolder {
itemViewCountView = (TextView) v.findViewById(R.id.itemViewCountView);
itemButton = (Button) v.findViewById(R.id.item_button);
}
}

View File

@ -35,6 +35,7 @@ import org.schabi.newpipe.BuildConfig;
import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.MainActivity;
import org.schabi.newpipe.R;
import org.schabi.newpipe.Themer;
import org.schabi.newpipe.extractor.Parser;
import java.io.PrintWriter;
@ -65,7 +66,7 @@ import java.util.Vector;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/
public class ErrorActivity extends AppCompatActivity {
public class ErrorActivity extends Themer {
public static class ErrorInfo implements Parcelable {
public int userAction;
public String request;

View File

@ -5,6 +5,7 @@ import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.v7.app.ActionBar;
@ -16,6 +17,8 @@ import android.view.ViewGroup;
import org.schabi.newpipe.R;
import java.util.Objects;
/**
* Created by Christian Schabesberger on 31.08.15.
@ -43,6 +46,10 @@ public class SettingsActivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceBundle) {
if (Objects.equals(PreferenceManager.getDefaultSharedPreferences(this)
.getString("theme", "1"), "0")) {
setTheme(R.style.DarkTheme);
}
getDelegate().installViewFactory();
getDelegate().onCreate(savedInstanceBundle);
super.onCreate(savedInstanceBundle);

View File

@ -1,6 +1,7 @@
package org.schabi.newpipe.settings;
import android.app.Activity;
import android.app.ListActivity;
import android.content.ClipData;
import android.content.Intent;
import android.content.SharedPreferences;
@ -55,6 +56,7 @@ public class SettingsFragment extends PreferenceFragment
String DOWNLOAD_PATH_PREFERENCE;
String DOWNLOAD_PATH_AUDIO_PREFERENCE;
String USE_TOR_KEY;
String THEME;
public static final int REQUEST_INSTALL_ORBOT = 0x1234;
@ -63,11 +65,12 @@ public class SettingsFragment extends PreferenceFragment
private ListPreference searchLanguagePreference;
private Preference downloadPathPreference;
private Preference downloadPathAudioPreference;
private Preference themePreference;
private SharedPreferences defaultPreferences;
@Override
public void onCreate(Bundle savedInstanceState) {
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
@ -81,6 +84,7 @@ public class SettingsFragment extends PreferenceFragment
SEARCH_LANGUAGE_PREFERENCE = getString(R.string.search_language_key);
DOWNLOAD_PATH_PREFERENCE = getString(R.string.download_path_key);
DOWNLOAD_PATH_AUDIO_PREFERENCE = getString(R.string.download_path_audio_key);
THEME = getString(R.string.theme_key);
USE_TOR_KEY = getString(R.string.use_tor_key);
// get pref objects
@ -92,6 +96,7 @@ public class SettingsFragment extends PreferenceFragment
(ListPreference) findPreference(SEARCH_LANGUAGE_PREFERENCE);
downloadPathPreference = findPreference(DOWNLOAD_PATH_PREFERENCE);
downloadPathAudioPreference = findPreference(DOWNLOAD_PATH_AUDIO_PREFERENCE);
themePreference = findPreference(THEME);
prefListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
@ -132,6 +137,11 @@ public class SettingsFragment extends PreferenceFragment
downloadPathAudioPreference
.setSummary(downloadPath);
}
else if (key == THEME)
{
String theme = sharedPreferences.getString(THEME, "Light");
themePreference.setSummary(theme);
}
updateSummary();
}
};
@ -161,7 +171,6 @@ public class SettingsFragment extends PreferenceFragment
activity.startActivityForResult(i, R.string.download_path_audio_key);
}
}
return super.onPreferenceTreeClick(preferenceScreen, preference);
}
@ -216,8 +225,8 @@ public class SettingsFragment extends PreferenceFragment
// installing the app does not necessarily return RESULT_OK
App.configureTor(requestCode == REQUEST_INSTALL_ORBOT
&& OrbotHelper.requestStartTor(a));
}
updateSummary();
super.onActivityResult(requestCode, resultCode, data);
}
@ -239,6 +248,9 @@ public class SettingsFragment extends PreferenceFragment
downloadPathAudioPreference.setSummary(
defaultPreferences.getString(DOWNLOAD_PATH_AUDIO_PREFERENCE,
getString(R.string.download_path_audio_summary)));
themePreference.setSummary(
defaultPreferences.getString(THEME,
getString(R.string.light_theme_title)));
}
@Override

View File

@ -66,7 +66,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/detail_stream_thumbnail_window_layout"
android:background="@color/light_background_color"
android:background="@color/dark_background_color"
android:visibility="gone">
<LinearLayout

View File

@ -14,6 +14,7 @@
android:id="@+id/detail_main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/dark_youtube_primary_color"
android:visibility="visible"
app:parallax_factor="1.9"
tools:ignore="UselessParent">
@ -68,7 +69,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/detail_stream_thumbnail_window_layout"
android:background="@color/light_background_color"
android:background="@color/dark_background_color"
android:visibility="gone">
<LinearLayout

View File

@ -10,6 +10,16 @@
<item name="android:windowBackground">@color/light_background_color</item>
</style>
<!-- Dark Theme-->
<style name="DarkTheme" parent="Theme.AppCompat">
<item name="android:actionBarStyle">@style/NewPipeActionbarTheme</item>
<item name="actionBarStyle">@style/NewPipeActionbarTheme</item>
<item name="colorPrimary">@color/dark_youtube_primary_color</item>
<item name="colorPrimaryDark">@color/light_youtube_dark_color</item>
<item name="colorAccent">@color/dark_youtube_accent_color</item>
<item name="android:windowBackground">@color/dark_background_color</item>
</style>
<style name="NewPipeActionbarTheme" parent="Widget.AppCompat.Light.ActionBar.Solid">
<item name="android:displayOptions">showHome</item>
<item name="displayOptions">showHome</item>

View File

@ -23,6 +23,16 @@
<item name="android:windowBackground">@color/light_background_color</item>
</style>
<!-- Dark Theme-->
<style name="DarkTheme" parent="Theme.AppCompat">
<item name="android:actionBarStyle">@style/NewPipeActionbarTheme</item>
<item name="actionBarStyle">@style/NewPipeActionbarTheme</item>
<item name="colorPrimary">@color/dark_youtube_primary_color</item>
<item name="colorPrimaryDark">@color/light_youtube_dark_color</item>
<item name="colorAccent">@color/dark_youtube_accent_color</item>
<item name="android:windowBackground">@color/dark_background_color</item>
</style>
<style name="NewPipeActionbarTheme" parent="Widget.AppCompat.Light.ActionBar.Solid">
<item name="android:displayOptions">showHome</item>
<item name="displayOptions">showHome</item>
@ -76,6 +86,11 @@
<item name="windowNoTitle">true</item>
</style>
<style name="DarkTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

View File

@ -44,7 +44,6 @@
android:title="@string/settings_category_appearance_title"
android:textAllCaps="true">
<!-- Not yet working.
<ListPreference
android:key="@string/theme_key"
android:title="@string/theme_title"
@ -52,7 +51,6 @@
android:entries="@array/theme_description_list"
android:entryValues="@array/theme_list"
android:defaultValue="@string/default_theme_value"/>
-->
<CheckBoxPreference
android:key="@string/show_play_with_kodi_key"