From b500c3f526a41fc2244077e4511dea68d41b4e11 Mon Sep 17 00:00:00 2001 From: wb9688 Date: Mon, 11 Sep 2017 15:37:41 +0200 Subject: [PATCH 1/7] Add service setting --- .../org/schabi/newpipe/fragments/MainFragment.java | 3 ++- app/src/main/res/values/settings_keys.xml | 11 +++++++++++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/content_settings.xml | 8 ++++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java index 236f95968..e2a36cb62 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java @@ -1,6 +1,7 @@ package org.schabi.newpipe.fragments; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.annotation.Nullable; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; @@ -75,7 +76,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_search: - NavigationHelper.openSearchFragment(getFragmentManager(), 0, ""); + NavigationHelper.openSearchFragment(getFragmentManager(), Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("service", "0")), ""); return true; } return super.onOptionsItemSelected(item); diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index c779e8216..8076e61f0 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -43,6 +43,17 @@ 144p + + YouTube + SoundCloud + + + 0 + 1 + + service + 0 + video_mp4 video_webm video_3gp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a5b3993d8..335be1e8d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -81,6 +81,7 @@ Next video Show next and similar videos URL not supported + Service Default content language Player Behavior diff --git a/app/src/main/res/xml/content_settings.xml b/app/src/main/res/xml/content_settings.xml index 63cd3cd01..eb262ea60 100644 --- a/app/src/main/res/xml/content_settings.xml +++ b/app/src/main/res/xml/content_settings.xml @@ -3,6 +3,14 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:title="@string/content"> + + Date: Thu, 14 Sep 2017 10:49:39 +0200 Subject: [PATCH 2/7] Change layout for audio-only streams --- .../fragments/detail/VideoDetailFragment.java | 14 ++++++++++++-- app/src/main/res/layout/fragment_video_detail.xml | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 5f954cad2..6b70ab6fc 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -329,7 +329,11 @@ public class VideoDetailFragment extends BaseStateFragment implement } break; case R.id.detail_thumbnail_root_layout: - openVideoPlayer(); + if (currentInfo.video_streams.isEmpty() && currentInfo.video_only_streams.isEmpty()) { + openBackgroundPlayer(); + } else { + openVideoPlayer(); + } break; case R.id.detail_title_root_layout: toggleTitleAndDescription(); @@ -1055,6 +1059,12 @@ public class VideoDetailFragment extends BaseStateFragment implement showSnackBarError(info.errors, UserAction.REQUESTED_STREAM, NewPipe.getNameOfService(info.service_id), info.url, 0); } + if (info.video_streams.isEmpty() && info.video_only_streams.isEmpty()) { + detailControlsBackground.setVisibility(View.GONE); + detailControlsPopup.setVisibility(View.GONE); + thumbnailPlayButton.setImageResource(R.drawable.ic_headset_white_24dp); + } + if (autoPlayEnabled) { openVideoPlayer(); // Only auto play in the first open @@ -1098,4 +1108,4 @@ public class VideoDetailFragment extends BaseStateFragment implement showError(getString(R.string.blocked_by_gema), false, R.drawable.gruese_die_gema); } -} \ No newline at end of file +} diff --git a/app/src/main/res/layout/fragment_video_detail.xml b/app/src/main/res/layout/fragment_video_detail.xml index 0d87809fc..4cafbcf9a 100644 --- a/app/src/main/res/layout/fragment_video_detail.xml +++ b/app/src/main/res/layout/fragment_video_detail.xml @@ -250,7 +250,7 @@ android:paddingBottom="6dp" android:paddingTop="6dp" android:text="@string/controls_background_title" - android:textSize="12sp"/> + android:textSize="12sp" /> From 442290d7f04861096903b13b9f1e88a51457bedb Mon Sep 17 00:00:00 2001 From: wb9688 Date: Thu, 14 Sep 2017 11:43:30 +0200 Subject: [PATCH 3/7] Hide spinner --- .../org/schabi/newpipe/fragments/detail/VideoDetailFragment.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java index 6b70ab6fc..b2e1d3aa4 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java @@ -1062,6 +1062,7 @@ public class VideoDetailFragment extends BaseStateFragment implement if (info.video_streams.isEmpty() && info.video_only_streams.isEmpty()) { detailControlsBackground.setVisibility(View.GONE); detailControlsPopup.setVisibility(View.GONE); + spinnerToolbar.setVisibility(View.GONE); thumbnailPlayButton.setImageResource(R.drawable.ic_headset_white_24dp); } From 25db3c2940de8d74c48885aac3646c3684cff481 Mon Sep 17 00:00:00 2001 From: wb9688 Date: Sat, 16 Sep 2017 09:47:15 +0200 Subject: [PATCH 4/7] Update NewPipeExtractor --- app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 941dc72d7..f97ffffe2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -45,7 +45,7 @@ dependencies { exclude module: 'support-annotations' } - compile 'com.github.TeamNewPipe:NewPipeExtractor:7ae274b' + compile 'com.github.TeamNewPipe:NewPipeExtractor:4a91e29' testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.10.19' From 54aa40eac1f3a3670a67765a6d59b5846f8d8c68 Mon Sep 17 00:00:00 2001 From: wb9688 Date: Sun, 19 Nov 2017 17:21:46 +0100 Subject: [PATCH 5/7] Add simple drawer for selecting service --- .../java/org/schabi/newpipe/MainActivity.java | 49 ++++++++++++++++++- .../newpipe/fragments/MainFragment.java | 5 +- app/src/main/res/layout/activity_main.xml | 28 ++++++++--- app/src/main/res/menu/drawer_items.xml | 5 ++ app/src/main/res/values/settings_keys.xml | 12 ++--- app/src/main/res/values/strings.xml | 6 +++ app/src/main/res/xml/content_settings.xml | 4 +- 7 files changed, 86 insertions(+), 23 deletions(-) create mode 100644 app/src/main/res/menu/drawer_items.xml diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 056db3500..7bc1747bb 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -28,8 +28,13 @@ import android.os.Looper; import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.design.widget.NavigationView; import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.view.GravityCompat; +import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBar; +import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; @@ -85,8 +90,50 @@ public class MainActivity extends AppCompatActivity implements HistoryListener { initFragments(); } - Toolbar toolbar = findViewById(R.id.toolbar); + final Toolbar toolbar = findViewById(R.id.toolbar); + final DrawerLayout drawer = findViewById(R.id.drawer_layout); + final NavigationView drawerItems = findViewById(R.id.navigation); setSupportActionBar(toolbar); + + final ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.drawer_open, R.string.drawer_close); + toggle.syncState(); + drawer.addDrawerListener(toggle); + + getSupportFragmentManager().addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() { + @Override + public void onBackStackChanged() { + if (getSupportFragmentManager().getBackStackEntryCount() > 1) { + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + toolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + onBackPressed(); + } + }); + } else { + getSupportActionBar().setDisplayHomeAsUpEnabled(false); + toggle.syncState(); + toolbar.setNavigationOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + drawer.openDrawer(GravityCompat.START); + } + }); + } + } + }); + + drawerItems.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { + public boolean onNavigationItemSelected(@NonNull MenuItem item) { + SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit(); + editor.putString("service", item.getTitle().toString()); + editor.apply(); + drawer.closeDrawers(); + return true; + } + }); + + sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); initHistory(); diff --git a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java index a3beb712c..f01807bf2 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/MainFragment.java @@ -30,13 +30,10 @@ import org.schabi.newpipe.fragments.list.kiosk.KioskFragment; import org.schabi.newpipe.fragments.subscription.SubscriptionFragment; import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.UserAction; -import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.KioskTranslator; import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.ThemeHelper; -import java.util.concurrent.ExecutionException; - public class MainFragment extends BaseFragment implements TabLayout.OnTabSelectedListener { private ViewPager viewPager; private boolean showBlankTab = false; @@ -139,7 +136,7 @@ public class MainFragment extends BaseFragment implements TabLayout.OnTabSelecte public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_search: - NavigationHelper.openSearchFragment(getFragmentManager(), Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("service", "0")), ""); + NavigationHelper.openSearchFragment(getFragmentManager(), NewPipe.getIdOfService(PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("service", "YouTube")), ""); return true; } return super.onOptionsItemSelected(item); diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 88a015e81..7eafc6c69 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,18 +1,30 @@ - + android:layout_height="match_parent"> + android:orientation="vertical" + tools:context="org.schabi.newpipe.MainActivity"> + - + + - + + \ No newline at end of file diff --git a/app/src/main/res/menu/drawer_items.xml b/app/src/main/res/menu/drawer_items.xml new file mode 100644 index 000000000..2f82327c3 --- /dev/null +++ b/app/src/main/res/menu/drawer_items.xml @@ -0,0 +1,5 @@ + + + + + \ 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 d088432c9..89cc71e44 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -46,16 +46,12 @@ 144p - - YouTube - SoundCloud - - - 0 - 1 + + @string/youtube + @string/soundcloud service - 0 + @string/youtube video_mp4 video_webm diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 65b7ed386..ded1d770c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -309,4 +309,10 @@ Details Audio Settings Hold To Enqueue + + + Open Drawer + Close Drawer + YouTube + SoundCloud diff --git a/app/src/main/res/xml/content_settings.xml b/app/src/main/res/xml/content_settings.xml index 8778b65f2..2a84ef0ef 100644 --- a/app/src/main/res/xml/content_settings.xml +++ b/app/src/main/res/xml/content_settings.xml @@ -5,8 +5,8 @@ From 1191455d377b40332270e3c8d327423b3fc83b63 Mon Sep 17 00:00:00 2001 From: wb9688 Date: Mon, 20 Nov 2017 16:04:18 +0100 Subject: [PATCH 6/7] Show selected service --- app/src/main/java/org/schabi/newpipe/MainActivity.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 7bc1747bb..bf628b8cb 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -50,6 +50,7 @@ import org.schabi.newpipe.database.history.dao.WatchHistoryDAO; import org.schabi.newpipe.database.history.model.HistoryEntry; import org.schabi.newpipe.database.history.model.SearchHistoryEntry; import org.schabi.newpipe.database.history.model.WatchHistoryEntry; +import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.stream.AudioStream; import org.schabi.newpipe.extractor.stream.StreamInfo; @@ -95,6 +96,8 @@ public class MainActivity extends AppCompatActivity implements HistoryListener { final NavigationView drawerItems = findViewById(R.id.navigation); setSupportActionBar(toolbar); + drawerItems.getMenu().getItem(NewPipe.getIdOfService(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("service", "YouTube"))).setChecked(true); + final ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.drawer_open, R.string.drawer_close); toggle.syncState(); drawer.addDrawerListener(toggle); @@ -125,15 +128,16 @@ public class MainActivity extends AppCompatActivity implements HistoryListener { drawerItems.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { public boolean onNavigationItemSelected(@NonNull MenuItem item) { + drawerItems.getMenu().getItem(NewPipe.getIdOfService(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("service", "YouTube"))).setChecked(false); SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit(); editor.putString("service", item.getTitle().toString()); editor.apply(); drawer.closeDrawers(); + drawerItems.getMenu().getItem(NewPipe.getIdOfService(PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getString("service", "YouTube"))).setChecked(true); return true; } }); - sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); initHistory(); From f5f8371865060b11be44f8fb5fd872c5a734fe0d Mon Sep 17 00:00:00 2001 From: wb9688 Date: Mon, 20 Nov 2017 19:31:33 +0100 Subject: [PATCH 7/7] Remove setting --- app/src/main/res/xml/content_settings.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/src/main/res/xml/content_settings.xml b/app/src/main/res/xml/content_settings.xml index 2a84ef0ef..dc5ce8868 100644 --- a/app/src/main/res/xml/content_settings.xml +++ b/app/src/main/res/xml/content_settings.xml @@ -2,15 +2,6 @@ - - - -