From 754bd826990bff86106e453931ed0202fc81e535 Mon Sep 17 00:00:00 2001 From: 59436419 Date: Fri, 30 Dec 2016 00:49:39 +0530 Subject: [PATCH 01/30] Added dark theme --- app/src/main/java/org/schabi/newpipe/App.java | 1 + .../org/schabi/newpipe/ChannelActivity.java | 8 +++++++- .../java/org/schabi/newpipe/MainActivity.java | 9 ++++++++- .../detail/VideoItemDetailActivity.java | 3 ++- .../newpipe/download/DownloadActivity.java | 6 +++--- .../newpipe/info_list/InfoItemHolder.java | 2 ++ .../schabi/newpipe/report/ErrorActivity.java | 3 ++- .../newpipe/settings/SettingsActivity.java | 7 +++++++ .../newpipe/settings/SettingsFragment.java | 18 +++++++++++++++--- .../layout-v18/fragment_videoitem_detail.xml | 2 +- .../res/layout/fragment_videoitem_detail.xml | 3 ++- app/src/main/res/values-v21/styles.xml | 10 ++++++++++ app/src/main/res/values/styles.xml | 15 +++++++++++++++ app/src/main/res/xml/settings.xml | 2 -- 14 files changed, 75 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java index f9b95c457..cb4dce3ea 100644 --- a/app/src/main/java/org/schabi/newpipe/App.java +++ b/app/src/main/java/org/schabi/newpipe/App.java @@ -48,6 +48,7 @@ public class App extends Application { @Override public void onCreate() { super.onCreate(); + // init crashreport try { final ACRAConfiguration acraConfig = new ConfigurationBuilder(this) diff --git a/app/src/main/java/org/schabi/newpipe/ChannelActivity.java b/app/src/main/java/org/schabi/newpipe/ChannelActivity.java index 83936475c..c8beb31f1 100644 --- a/app/src/main/java/org/schabi/newpipe/ChannelActivity.java +++ b/app/src/main/java/org/schabi/newpipe/ChannelActivity.java @@ -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 @@ -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); diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index bfeb74287..2e94443f9 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -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 . */ -public class MainActivity extends AppCompatActivity { +public class MainActivity extends Themer { private Fragment mainFragment = null; diff --git a/app/src/main/java/org/schabi/newpipe/detail/VideoItemDetailActivity.java b/app/src/main/java/org/schabi/newpipe/detail/VideoItemDetailActivity.java index 591017a92..f47e726df 100644 --- a/app/src/main/java/org/schabi/newpipe/detail/VideoItemDetailActivity.java +++ b/app/src/main/java/org/schabi/newpipe/detail/VideoItemDetailActivity.java @@ -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 . */ -public class VideoItemDetailActivity extends AppCompatActivity { +public class VideoItemDetailActivity extends Themer { /** * Removes invisible separators (\p{Z}) and punctuation characters including diff --git a/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java b/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java index a7e52c486..98e4eddd7 100644 --- a/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java +++ b/app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java @@ -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"; diff --git a/app/src/main/java/org/schabi/newpipe/info_list/InfoItemHolder.java b/app/src/main/java/org/schabi/newpipe/info_list/InfoItemHolder.java index dbba4ac5f..a2b000e2b 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/InfoItemHolder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/InfoItemHolder.java @@ -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); } + } diff --git a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java index 8ebb9b155..b87fa8af8 100644 --- a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java @@ -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 . */ -public class ErrorActivity extends AppCompatActivity { +public class ErrorActivity extends Themer { public static class ErrorInfo implements Parcelable { public int userAction; public String request; diff --git a/app/src/main/java/org/schabi/newpipe/settings/SettingsActivity.java b/app/src/main/java/org/schabi/newpipe/settings/SettingsActivity.java index e62f90c45..9ca0490d4 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SettingsActivity.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SettingsActivity.java @@ -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); diff --git a/app/src/main/java/org/schabi/newpipe/settings/SettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/SettingsFragment.java index a5521dfc5..c9c7fe134 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SettingsFragment.java @@ -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 diff --git a/app/src/main/res/layout-v18/fragment_videoitem_detail.xml b/app/src/main/res/layout-v18/fragment_videoitem_detail.xml index 003bb393e..82abd39fe 100644 --- a/app/src/main/res/layout-v18/fragment_videoitem_detail.xml +++ b/app/src/main/res/layout-v18/fragment_videoitem_detail.xml @@ -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"> @@ -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"> @color/light_background_color + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml new file mode 100644 index 000000000..68928bdbc --- /dev/null +++ b/app/src/main/res/values/attrs.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index e17179117..77d232ccb 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -25,14 +25,16 @@ show_play_with_kodi theme - 0 + @string/light_theme_title - @string/dark_theme_title @string/light_theme_title + @string/dark_theme_title + @string/black_theme_title - 0 - 1 + @string/light_theme_title + @string/dark_theme_title + @string/black_theme_title default_audio_format diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 39532aefd..6fc947f54 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -46,8 +46,9 @@ WebM — free format m4a — better quality Theme - Dark Light + Dark + Black Download diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index dbb073b9e..97040f014 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,6 +1,6 @@ - + + + + + + + + diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index cc42de70a..7330643ee 100644 --- a/app/src/main/res/xml/settings.xml +++ b/app/src/main/res/xml/settings.xml @@ -43,7 +43,7 @@ android:key="@string/settings_category_appearance" android:title="@string/settings_category_appearance_title" android:textAllCaps="true"> - +. Date: Tue, 17 Jan 2017 20:31:14 +0530 Subject: [PATCH 18/30] Added dark theme --- .../newpipe/settings/SettingsFragment.java | 1 - app/src/main/res/values-v21/styles.xml | 20 ------------------- app/src/main/res/values/settings_keys.xml | 2 -- app/src/main/res/values/styles.xml | 20 ------------------- 4 files changed, 43 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/settings/SettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/SettingsFragment.java index 0e7e6bb0a..6f843d028 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/SettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/SettingsFragment.java @@ -68,7 +68,6 @@ public class SettingsFragment extends PreferenceFragment private Preference downloadPathAudioPreference; private Preference themePreference; private SharedPreferences defaultPreferences; - private Preference themePreference; @Override public void onCreate(final Bundle savedInstanceState) { diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml index a1934ba07..89e8c0784 100644 --- a/app/src/main/res/values-v21/styles.xml +++ b/app/src/main/res/values-v21/styles.xml @@ -27,26 +27,6 @@ @drawable/ic_file_download_white_24dp - - - - - - - - - - - - @@ -25,6 +26,7 @@ @drawable/ic_thumb_down_white_24dp @drawable/ic_headset_white_24dp @drawable/ic_file_download_white_24dp + @drawable/ic_share_white_24dp @@ -27,6 +28,7 @@ @drawable/ic_headset_white_24dp @drawable/ic_file_download_white_24dp @drawable/ic_share_white_24dp + @drawable/ic_cast_white_24dp @@ -29,6 +30,7 @@ @drawable/ic_file_download_white_24dp @drawable/ic_share_white_24dp @drawable/ic_cast_white_24dp + @drawable/ic_rss_feed_black_24dp @@ -45,6 +46,7 @@ @drawable/ic_file_download_white_24dp @drawable/ic_share_white_24dp @drawable/ic_cast_white_24dp + @drawable/ic_rss_feed_black_24dp + - -