1
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-09-27 18:20:51 +02:00

Compare commits

..

65 Commits

Author SHA1 Message Date
Christian Schabesberger
082c6128ad moved on to 0.8.9 2017-01-31 18:28:47 +01:00
Christian Schabesberger
7c9771873b Merge branch 'master' of git://github.com/ksyko/NewPipe into jf 2017-01-31 18:25:30 +01:00
Christian Schabesberger
7257cdacc8 fix background button problem 2017-01-31 18:23:22 +01:00
Christian Schabesberger
140b480f82 url signature fix
* fixed stacktrace
* changed player url
* took regex fix from youtube-dl

final fix taken from youtube-dl
2017-01-31 18:06:44 +01:00
Christian Schabesberger
77db2f8a48 update support Framework 2017-01-31 10:58:53 +01:00
naofum
22bc81b0eb Translated using Weblate (Japanese)
Currently translated at 100.0% (142 of 142 strings)
2017-01-27 15:50:44 +01:00
Mladen Pejaković
b52b3d4be0 Translated using Weblate (Serbian)
Currently translated at 100.0% (142 of 142 strings)
2017-01-26 18:49:26 +01:00
Nathan Follens
f845098b42 Translated using Weblate (Dutch)
Currently translated at 100.0% (142 of 142 strings)
2017-01-26 16:48:57 +01:00
Weblate
0f7397e3b8 Merge remote-tracking branch 'origin/master' 2017-01-26 15:46:09 +01:00
Shaye Faletha
0b9d99fdc9 Translated using Weblate (Polish)
Currently translated at 99.2% (140 of 141 strings)
2017-01-26 15:46:06 +01:00
59436419
9a1da5cc75 Made changes for ICS and JB 2017-01-26 12:07:41 +05:30
Christian Schabesberger
9e76f94cf6 update support lib and move on to 0.8.8 2017-01-22 14:47:05 +01:00
Christian Schabesberger
7d6b92e064 Merge branch 'feature-improve-search-fragment' of git://github.com/coffeemakr/NewPipe into cofe 2017-01-22 14:42:36 +01:00
Christian Schabesberger
849a45a3ca resolve conflict 2017-01-22 14:26:01 +01:00
Christian Schabesberger
7ddea5a71b Merge branch 'feature-accept-embed-links' of git://github.com/coffeemakr/NewPipe into url 2017-01-22 13:55:53 +01:00
Christian Schabesberger
5d81358c15 rename Themer to ThemableActivity 2017-01-22 13:48:50 +01:00
Christian Schabesberger
492aad9d70 Merge branch 'master' of git://github.com/ksyko/NewPipe into kyko 2017-01-22 13:32:39 +01:00
Weblate
647cfcd401 Merge remote-tracking branch 'origin/master' 2017-01-21 15:44:14 +01:00
Yann Hodiesne
c60d98e52d Translated using Weblate (French)
Currently translated at 97.1% (137 of 141 strings)
2017-01-21 15:44:14 +01:00
Osoitz
d3cfac6b15 Translated using Weblate (Basque)
Currently translated at 37.5% (53 of 141 strings)
2017-01-21 15:44:11 +01:00
Coffeemakr
7fb4e5a143 Rename download db sqlite file
Rename the sqlite database to "downloads.db" instead of "newpipe.db"
to make sure the file will create a conflicts later.
2017-01-20 18:57:30 +01:00
Coffeemakr
8e451b2a83 Use fragments setHasOptionsMenu
Remove complications by allowing android to handle fragment's
options menu.

See https://developer.android.com/guide/components/fragments.html#ActionBar
2017-01-19 19:39:33 +01:00
ksyko
8083f06fe7 Update SettingsFragment.java 2017-01-18 00:12:36 +05:30
59436419
44521a2e56 Added dark theme 2017-01-17 22:35:23 +05:30
59436419
dfeed3d0eb Added dark theme 2017-01-17 22:31:00 +05:30
59436419
081a45b70d Added dark theme 2017-01-17 22:13:33 +05:30
59436419
616a721bba Added dark theme 2017-01-17 21:43:30 +05:30
59436419
c9aa553b32 Added dark theme 2017-01-17 20:54:00 +05:30
59436419
e3d59c3cff Added dark theme 2017-01-17 20:47:12 +05:30
59436419
df51635674 Added dark theme 2017-01-17 20:33:54 +05:30
59436419
1e81f61760 Added dark theme 2017-01-17 20:31:14 +05:30
59436419
a4043eab83 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	app/src/main/java/org/schabi/newpipe/Themer.java
#	app/src/main/java/org/schabi/newpipe/download/DownloadActivity.java
#	app/src/main/java/org/schabi/newpipe/settings/SettingsActivity.java
#	app/src/main/res/layout-v18/fragment_videoitem_detail.xml
#	app/src/main/res/layout/fragment_videoitem_detail.xml
#	app/src/main/res/xml/settings.xml
2017-01-17 16:18:00 +05:30
59436419
60dc19d2bc Added Dark Theme 2017-01-17 16:13:14 +05:30
ksyko
a2e4585fe8 Update InfoItemHolder.java 2017-01-17 16:13:02 +05:30
ksyko
b5df281447 Update fragment_videoitem_detail.xml 2017-01-17 16:13:02 +05:30
ksyko
650917f9f9 Update fragment_videoitem_detail.xml 2017-01-17 16:13:02 +05:30
ksyko
3a9c95a9ae Update fragment_videoitem_detail.xml 2017-01-17 16:13:01 +05:30
59436419
5458acfcad Added dark theme 2017-01-17 16:13:01 +05:30
59436419
68e80e6054 Added dark theme 2017-01-17 16:13:01 +05:30
Christian Schabesberger
e4aa69b8d3 add some super.function() thingies 2017-01-16 16:06:54 +01:00
Coffeemakr
dfd40e43da Fix for #407 2017-01-16 13:01:52 +01:00
Coffeemakr
7efd111d9c Improve Search fragment
* Keep search query when fragment is restored
 * Simplify SuggestionListAdapter
   * Use ResourceCursorAdapter for view creation
 * Fix deprecation warning
 * Some clean code
2017-01-16 07:33:58 +01:00
Matej U
6809172203 Translated using Weblate (Slovenian)
Currently translated at 99.2% (140 of 141 strings)
2017-01-15 12:46:28 +01:00
Coffeemaker
40a4343f06 Translated using Weblate (German)
Currently translated at 98.5% (139 of 141 strings)
2017-01-13 18:45:02 +01:00
Matej U
cd9333b39e Translated using Weblate (Slovenian)
Currently translated at 98.5% (139 of 141 strings)
2017-01-12 21:46:19 +01:00
Mladen Pejaković
82d426c781 Translated using Weblate (Serbian)
Currently translated at 100.0% (141 of 141 strings)
2017-01-12 21:46:11 +01:00
YFdyh000
c7e773de25 Translated using Weblate (Chinese (Simplified))
Currently translated at 98.5% (139 of 141 strings)
2017-01-12 18:44:21 +01:00
Coffeemakr
2ded33110f Improve YoutubeStreamUrlIdHandler
* Make it a singelton
 * Accept embed links
 * Accept share links (youtube.com/shared?ci=...)
 * Add tests
 * Accept host case insensititve
2017-01-11 17:25:53 +01:00
zmni
b26c0aa9da Translated using Weblate (Indonesian)
Currently translated at 100.0% (141 of 141 strings)
2017-01-11 16:51:32 +01:00
Mladen Pejaković
2fc8fb6f17 Translated using Weblate (Serbian)
Currently translated at 100.0% (141 of 141 strings)
2017-01-10 21:08:24 +01:00
Coffeemakr
ea76f1d6e2 Improve DownloadManager and -Service
* Fix permission at some places
 * Fix access problem for downloaded files with external player
 * Store finished Downloads
 * Remove binding to DownloadService just to download a file
 * Javadoc
 * Code improvements
2017-01-10 17:48:55 +01:00
naofum
7cda1d116b Translated using Weblate (Japanese)
Currently translated at 100.0% (141 of 141 strings)
2017-01-10 17:03:28 +01:00
Weblate
8bf7a1a9db Merge remote-tracking branch 'origin/master' 2017-01-10 17:02:24 +01:00
naofum
0aa0ad65c0 Translated using Weblate (Japanese)
Currently translated at 100.0% (140 of 140 strings)
2017-01-10 17:02:21 +01:00
Coffeemakr
53ff58daa3 DownloadManagerService: Don't bind if no permissions 2017-01-10 13:35:16 +01:00
Christian Schabesberger
b3225bebe6 fix recaptch weblate conflict 2017-01-09 22:46:07 +01:00
Allan Nordhøy
4beafad71f Translated using Weblate (Norwegian Bokmål)
Currently translated at 92.8% (130 of 140 strings)
2017-01-09 21:45:13 +01:00
Allan Nordhøy
c96f933626 Translated using Weblate (English)
Currently translated at 100.0% (140 of 140 strings)
2017-01-09 21:45:12 +01:00
LNJ
bea6359d5f Translated using Weblate (German)
Currently translated at 99.2% (139 of 140 strings)
2017-01-09 21:45:04 +01:00
ksyko
1b9a6e53ce Update InfoItemHolder.java 2016-12-31 22:32:16 +05:30
ksyko
c7abf377eb Update fragment_videoitem_detail.xml 2016-12-31 21:51:41 +05:30
ksyko
175d8ce572 Update fragment_videoitem_detail.xml 2016-12-31 21:43:01 +05:30
ksyko
1708a401cf Update fragment_videoitem_detail.xml 2016-12-31 21:42:04 +05:30
59436419
141278e668 Added dark theme 2016-12-31 13:46:52 +05:30
59436419
754bd82699 Added dark theme 2016-12-30 01:07:27 +05:30
133 changed files with 1942 additions and 747 deletions

View File

@@ -8,8 +8,8 @@ android {
applicationId "org.schabi.newpipe"
minSdkVersion 15
targetSdkVersion 25
versionCode 21
versionName "0.8.7"
versionCode 23
versionName "0.8.9"
}
buildTypes {
release {
@@ -32,10 +32,10 @@ android {
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:design:25.1.1'
compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'org.jsoup:jsoup:1.8.3'
compile 'org.mozilla:rhino:1.7.7'
compile 'info.guardianproject.netcipher:netcipher:1.2'
@@ -46,5 +46,6 @@ dependencies {
compile 'com.google.code.gson:gson:2.4'
compile 'com.nononsenseapps:filepicker:3.0.0'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
compile 'ch.acra:acra:4.9.0'
}

View File

@@ -161,6 +161,16 @@
<activity
android:name=".ReCaptchaActivity"
android:label="@string/reCaptchaActivity" />
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
</application>
</manifest>

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,11 @@ public class ChannelActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
if (PreferenceManager.getDefaultSharedPreferences(this)
.getString("theme", getResources().getString(R.string.light_theme_title)).
equals(getResources().getString(R.string.dark_theme_title))) {
setTheme(R.style.DarkTheme_NoActionBar);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_channel);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
@@ -128,7 +135,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

@@ -4,13 +4,13 @@ import android.content.Intent;
import android.media.AudioManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.NavUtils;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import org.schabi.newpipe.settings.SettingsActivity;
import org.schabi.newpipe.util.PermissionHelper;
/**
* Created by Christian Schabesberger on 02.08.16.
@@ -32,7 +32,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 ThemableActivity {
private Fragment mainFragment = null;
@@ -40,7 +40,6 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
mainFragment = getSupportFragmentManager()
.findFragmentById(R.id.search_fragment);
@@ -52,8 +51,6 @@ public class MainActivity extends AppCompatActivity {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
mainFragment.onCreateOptionsMenu(menu, inflater);
return true;
}
@@ -74,13 +71,15 @@ public class MainActivity extends AppCompatActivity {
return true;
}
case R.id.action_show_downloads: {
if(!PermissionHelper.checkStoragePermissions(this)) {
return false;
}
Intent intent = new Intent(this, org.schabi.newpipe.download.DownloadActivity.class);
startActivity(intent);
return true;
}
default:
return mainFragment.onOptionsItemSelected(item) ||
super.onOptionsItemSelected(item);
return super.onOptionsItemSelected(item);
}
}
}

View File

@@ -0,0 +1,19 @@
package org.schabi.newpipe;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
public class ThemableActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (PreferenceManager.getDefaultSharedPreferences(this)
.getString("theme", getResources().getString(R.string.light_theme_title)).
equals(getResources().getString(R.string.dark_theme_title))) {
setTheme(R.style.DarkTheme);
}
}
}

View File

@@ -125,10 +125,13 @@ public class StreamInfoWorker {
e.printStackTrace();
} catch (YoutubeStreamExtractor.DecryptException de) {
// custom service related exceptions
ErrorActivity.reportError(h, a, de, VideoItemDetailFragment.class, null,
ErrorActivity.ErrorInfo.make(ErrorActivity.REQUESTED_STREAM,
service.getServiceInfo().name, videoUrl, R.string.youtube_signature_decryption_error));
h.post(new Runnable() {
@Override
public void run() {
onStreamInfoReceivedListener.onError(R.string.youtube_signature_decryption_error);
a.finish();
}
});
de.printStackTrace();

View File

@@ -5,7 +5,6 @@ import android.media.AudioManager;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.NavUtils;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@@ -14,6 +13,7 @@ import android.widget.Toast;
import org.schabi.newpipe.App;
import org.schabi.newpipe.MainActivity;
import org.schabi.newpipe.R;
import org.schabi.newpipe.ThemableActivity;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
@@ -39,7 +39,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 ThemableActivity {
/**
* Removes invisible separators (\p{Z}) and punctuation characters including
@@ -141,6 +141,7 @@ public class VideoItemDetailActivity extends AppCompatActivity {
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(VideoItemDetailFragment.VIDEO_URL, videoUrl);
outState.putInt(VideoItemDetailFragment.STREAMING_SERVICE, currentStreamingService);
outState.putBoolean(VideoItemDetailFragment.AUTO_PLAY, false);
@@ -148,6 +149,7 @@ public class VideoItemDetailActivity extends AppCompatActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
super.onOptionsItemSelected(item);
int id = item.getItemId();
if (id == android.R.id.home) {
// This ID represents the Home or Up button. In the case of this
@@ -162,19 +164,10 @@ public class VideoItemDetailActivity extends AppCompatActivity {
NavUtils.navigateUpTo(this, intent);
return true;
} else {
return fragment.onOptionsItemSelected(item) ||
super.onOptionsItemSelected(item);
return super.onOptionsItemSelected(item);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
fragment.onCreateOptionsMenu(menu, getMenuInflater());
return true;
}
/**
* Retrieves all Strings which look remotely like URLs from a text.
* Used if NewPipe was called through share menu.

View File

@@ -21,6 +21,7 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
@@ -30,7 +31,6 @@ import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.view.MenuItem;
import android.widget.Toast;
import com.google.android.exoplayer.util.Util;
@@ -39,26 +39,26 @@ import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
import java.util.Vector;
import org.schabi.newpipe.ActivityCommunicator;
import org.schabi.newpipe.ChannelActivity;
import org.schabi.newpipe.ReCaptchaActivity;
import org.schabi.newpipe.extractor.stream_info.StreamInfo;
import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfo;
import org.schabi.newpipe.info_list.InfoItemBuilder;
import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.ImageErrorLoadingListener;
import org.schabi.newpipe.Localization;
import org.schabi.newpipe.R;
import org.schabi.newpipe.ReCaptchaActivity;
import org.schabi.newpipe.download.DownloadDialog;
import org.schabi.newpipe.extractor.stream_info.AudioStream;
import org.schabi.newpipe.extractor.MediaFormat;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.stream_info.AudioStream;
import org.schabi.newpipe.extractor.stream_info.StreamInfo;
import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfo;
import org.schabi.newpipe.extractor.stream_info.VideoStream;
import org.schabi.newpipe.info_list.InfoItemBuilder;
import org.schabi.newpipe.player.BackgroundPlayer;
import org.schabi.newpipe.player.PlayVideoActivity;
import org.schabi.newpipe.player.ExoPlayerActivity;
import org.schabi.newpipe.player.PlayVideoActivity;
import org.schabi.newpipe.report.ErrorActivity;
import java.util.Vector;
import org.schabi.newpipe.util.PermissionHelper;
import static android.app.Activity.RESULT_OK;
import static org.schabi.newpipe.ReCaptchaActivity.RECAPTCHA_REQUEST;
@@ -144,6 +144,7 @@ public class VideoItemDetailFragment extends Fragment {
TextView similarTitle = (TextView) activity.findViewById(R.id.detail_similar_title);
Button backgroundButton = (Button)
activity.findViewById(R.id.detail_stream_thumbnail_window_background_button);
View thumbnailView = activity.findViewById(R.id.detail_thumbnail_view);
View topView = activity.findViewById(R.id.detailTopView);
Button channelButton = (Button) activity.findViewById(R.id.channel_button);
@@ -275,6 +276,14 @@ public class VideoItemDetailFragment extends Fragment {
}
});
//todo: make backgroundButton handle this
thumbnailView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
playVideo(info);
}
});
if (info.channel_url != null && info.channel_url != "") {
channelButton.setOnClickListener(new View.OnClickListener() {
@Override
@@ -393,6 +402,10 @@ public class VideoItemDetailFragment extends Fragment {
actionBarHandler.setOnDownloadListener(new ActionBarHandler.OnActionListener() {
@Override
public void onActionSelected(int selectedStreamId) {
if(!PermissionHelper.checkStoragePermissions(getActivity())) {
return;
}
try {
Bundle args = new Bundle();
@@ -629,6 +642,7 @@ public class VideoItemDetailFragment extends Fragment {
onNotSpecifiedContentError();
}
});
setHasOptionsMenu(true);
}
@Override
@@ -647,10 +661,9 @@ public class VideoItemDetailFragment extends Fragment {
}
@Override
public void onActivityCreated(Bundle savedInstanceBundle) {
super.onActivityCreated(savedInstanceBundle);
public void onStart() {
super.onStart();
Activity a = getActivity();
infoItemBuilder = new InfoItemBuilder(a, a.findViewById(android.R.id.content));
if (android.os.Build.VERSION.SDK_INT < 18) {
@@ -779,11 +792,13 @@ public class VideoItemDetailFragment extends Fragment {
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
actionBarHandler.setupMenu(menu, inflater);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
super.onOptionsItemSelected(item);
return actionBarHandler.onItemSelected(item);
}
@@ -806,6 +821,7 @@ public class VideoItemDetailFragment extends Fragment {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case RECAPTCHA_REQUEST:
if (resultCode == RESULT_OK) {

View File

@@ -13,8 +13,8 @@ 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.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -28,8 +28,10 @@ import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import org.schabi.newpipe.ThemableActivity;
import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.R;
import org.schabi.newpipe.settings.NewPipeSettings;
import org.schabi.newpipe.settings.SettingsActivity;
import java.io.File;
@@ -42,7 +44,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 ThemableActivity implements AdapterView.OnItemClickListener{
public static final String INTENT_DOWNLOAD = "us.shandian.giga.intent.DOWNLOAD";
@@ -53,26 +55,11 @@ public class DownloadActivity extends AppCompatActivity implements AdapterView.O
private MissionsFragment mFragment;
private DownloadManager mManager;
private DownloadManagerService.DMBinder mBinder;
private String mPendingUrl;
private SharedPreferences mPrefs;
private ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName p1, IBinder binder) {
mBinder = (DownloadManagerService.DMBinder) binder;
mManager = mBinder.getDownloadManager();
}
@Override
public void onServiceDisconnected(ComponentName p1) {
}
};
@Override
@TargetApi(21)
protected void onCreate(Bundle savedInstanceState) {
@@ -83,7 +70,6 @@ public class DownloadActivity extends AppCompatActivity implements AdapterView.O
Intent i = new Intent();
i.setClass(this, DownloadManagerService.class);
startService(i);
bindService(i, mConnection, Context.BIND_AUTO_CREATE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_downloader);
@@ -91,7 +77,7 @@ public class DownloadActivity extends AppCompatActivity implements AdapterView.O
//noinspection ConstantConditions
// its ok if this failes, we will catch that error later, and send it as report
// its ok if this fails, we will catch that error later, and send it as report
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(R.string.downloads_title);
@@ -202,22 +188,24 @@ public class DownloadActivity extends AppCompatActivity implements AdapterView.O
@Override
public boolean onMenuItemClick(MenuItem item) {
if (item.getItemId() == R.id.okay) {
String location;
if(audioButton.isChecked()) {
location = NewPipeSettings.getAudioDownloadPath(DownloadActivity.this);
} else {
location = NewPipeSettings.getVideoDownloadPath(DownloadActivity.this);
}
String fName = name.getText().toString().trim();
File f = new File(mManager.getLocation() + "/" + fName);
File f = new File(location, fName);
if (f.exists()) {
Toast.makeText(DownloadActivity.this, R.string.msg_exists, Toast.LENGTH_SHORT).show();
} else {
while (mBinder == null);
int res = mManager.startMission(
getIntent().getData().toString(),
fName,
audioButton.isChecked(),
threads.getProgress() + 1);
mBinder.onMissionAdded(mManager.getMission(res));
DownloadManagerService.startMission(
DownloadActivity.this,
getIntent().getData().toString(), location, fName,
audioButton.isChecked(), threads.getProgress() + 1);
mFragment.notifyChange();
mPrefs.edit().putInt(THREADS, threads.getProgress() + 1).commit();
@@ -273,8 +261,8 @@ public class DownloadActivity extends AppCompatActivity implements AdapterView.O
return true;
}
default:
return mFragment.onOptionsItemSelected(item) ||
super.onOptionsItemSelected(item);
return super.onOptionsItemSelected(item);
}
}
}

View File

@@ -26,6 +26,8 @@ import android.widget.TextView;
import org.schabi.newpipe.App;
import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.settings.NewPipeSettings;
import java.io.File;
import java.util.ArrayList;
@@ -65,24 +67,6 @@ public class DownloadDialog extends DialogFragment {
public static final String AUDIO_URL = "audio_url";
public static final String VIDEO_URL = "video_url";
private DownloadManager mManager;
private DownloadManagerService.DMBinder mBinder;
private ServiceConnection mConnection = new ServiceConnection() {
@Override
public void onServiceConnected(ComponentName p1, IBinder binder) {
mBinder = (DownloadManagerService.DMBinder) binder;
mManager = mBinder.getDownloadManager();
}
@Override
public void onServiceDisconnected(ComponentName p1) {
}
};
public DownloadDialog() {
}
@@ -102,12 +86,6 @@ public class DownloadDialog extends DialogFragment {
if(ContextCompat.checkSelfPermission(this.getContext(),Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED)
ActivityCompat.requestPermissions(getActivity(),new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},0);
Intent i = new Intent();
i.setClass(getContext(), DownloadManagerService.class);
getContext().startService(i);
getContext().bindService(i, mConnection, Context.BIND_AUTO_CREATE);
return inflater.inflate(R.layout.dialog_url, container);
}
@@ -219,36 +197,22 @@ public class DownloadDialog extends DialogFragment {
String fName = name.getText().toString().trim();
// todo: add timeout? would be bad if the thread gets locked dueto this.
while (mBinder == null);
if(audioButton.isChecked()){
int res = mManager.startMission(
arguments.getString(AUDIO_URL),
fName + arguments.getString(FILE_SUFFIX_AUDIO),
audioButton.isChecked(),
threads.getProgress() + 1);
DownloadMission mission = mManager.getMission(res);
mBinder.onMissionAdded(mission);
// add download listener to allow media scan notification
DownloadListener listener = new DownloadListener(getContext(), mission);
mission.addListener(listener);
boolean isAudio = audioButton.isChecked();
String url, location, filename;
if(isAudio) {
url = arguments.getString(AUDIO_URL);
location = NewPipeSettings.getAudioDownloadPath(getContext());
filename = fName + arguments.getString(FILE_SUFFIX_AUDIO);
} else {
url = arguments.getString(VIDEO_URL);
location = NewPipeSettings.getVideoDownloadPath(getContext());
filename = fName + arguments.getString(FILE_SUFFIX_VIDEO);
}
if(videoButton.isChecked()){
int res = mManager.startMission(
arguments.getString(VIDEO_URL),
fName + arguments.getString(FILE_SUFFIX_VIDEO),
audioButton.isChecked(),
threads.getProgress() + 1);
DownloadMission mission = mManager.getMission(res);
mBinder.onMissionAdded(mission);
// add download listener to allow media scan notification
DownloadListener listener = new DownloadListener(getContext(), mission);
mission.addListener(listener);
}
DownloadManagerService.startMission(getContext(), url, location, filename, isAudio,
threads.getProgress() + 1);
getDialog().dismiss();
}
private void download(String url, String title,

View File

@@ -1,62 +0,0 @@
package org.schabi.newpipe.download;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import us.shandian.giga.get.DownloadMission;
import us.shandian.giga.get.DownloadMission.MissionListener;
/**
* Created by erwin on 06.11.16.
*
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
* DownloadListener.java is part of NewPipe.
*
* NewPipe is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* NewPipe is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/
class DownloadListener implements MissionListener
{
DownloadMission mMission;
Context mContext;
public DownloadListener(Context context, DownloadMission mission)
{
super();
mMission = mission;
mContext = context;
}
@Override
public void onProgressUpdate(long done, long total)
{
// do nothing special ...
}
@Override
public void onFinish()
{
// notify media scanner on downloaded media file ...
mContext.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
Uri.parse( "file://" + mMission.location
+ "/" + mMission.name)));
}
@Override
public void onError(int errCode)
{
// do nothing special ...
}
}

View File

@@ -42,7 +42,7 @@ import info.guardianproject.netcipher.NetCipher;
*/
// TODO: FOR HEVEN SAKE !!! DO NOT SIMPLY USE ASYNCTASK. MAKE THIS A PROPER SERVICE !!!
// TODO: FOR HEAVEN SAKE !!! DO NOT SIMPLY USE ASYNCTASK. MAKE THIS A PROPER SERVICE !!!
public class FileDownloader extends AsyncTask<Void, Integer, Void> {
public static final String TAG = "FileDownloader";

View File

@@ -42,15 +42,23 @@ public class Parser {
}
public static String matchGroup1(String pattern, String input) throws RegexException {
return matchGroup(pattern, input, 1);
}
public static String matchGroup(String pattern, String input, int group) throws RegexException {
Pattern pat = Pattern.compile(pattern);
Matcher mat = pat.matcher(input);
boolean foundMatch = mat.find();
if (foundMatch) {
return mat.group(1);
return mat.group(group);
}
else {
//Log.e(TAG, "failed to find pattern \""+pattern+"\" inside of \""+input+"\"");
throw new RegexException("failed to find pattern \""+pattern+" inside of "+input+"\"");
if(input.length() > 1024) {
throw new RegexException("failed to find pattern \""+pattern);
} else {
throw new RegexException("failed to find pattern \"" + pattern + " inside of " + input + "\"");
}
}
}

View File

@@ -4,7 +4,6 @@ import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import java.io.IOException;
import java.util.List;
/**
* Created by Christian Schabesberger on 10.08.15.
@@ -26,7 +25,6 @@ import java.util.List;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/
@SuppressWarnings("ALL")
public abstract class SearchEngine {
public static class NothingFoundException extends ExtractionException {
public NothingFoundException(String message) {

View File

@@ -85,18 +85,18 @@ public class YoutubeSearchEngine extends SearchEngine {
Element el;
// both types of spell correction item
if (!((el = item.select("div[class*=\"spell-correction\"]").first()) == null)) {
if ((el = item.select("div[class*=\"spell-correction\"]").first()) != null) {
collector.setSuggestion(el.select("a").first().text());
if(list.children().size() == 1) {
throw new NothingFoundException("Did you mean: " + el.select("a").first().text());
}
// search message item
} else if (!((el = item.select("div[class*=\"search-message\"]").first()) == null)) {
} else if ((el = item.select("div[class*=\"search-message\"]").first()) != null) {
//result.errorMessage = el.text();
throw new NothingFoundException(el.text());
// video item type
} else if (!((el = item.select("div[class*=\"yt-lockup-video\"").first()) == null)) {
} else if ((el = item.select("div[class*=\"yt-lockup-video\"").first()) != null) {
collector.commit(extractPreviewInfo(el));
} else {
//noinspection ConstantConditions

View File

@@ -46,7 +46,7 @@ public class YoutubeService extends StreamingService {
@Override
public StreamExtractor getExtractorInstance(String url)
throws ExtractionException, IOException {
UrlIdHandler urlIdHandler = new YoutubeStreamUrlIdHandler();
UrlIdHandler urlIdHandler = YoutubeStreamUrlIdHandler.getInstance();
if(urlIdHandler.acceptUrl(url)) {
return new YoutubeStreamExtractor(urlIdHandler, url, getServiceId());
}
@@ -61,7 +61,7 @@ public class YoutubeService extends StreamingService {
@Override
public UrlIdHandler getUrlIdHandlerInstance() {
return new YoutubeStreamUrlIdHandler();
return YoutubeStreamUrlIdHandler.getInstance();
}
@Override

View File

@@ -88,7 +88,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
// $$el_type$$ will be replaced by the actual el_type (se the declarations below)
private static final String GET_VIDEO_INFO_URL =
"https://www.youtube.com/get_video_info?video_id=%%video_id%%$$el_type$$&ps=default&eurl=&gl=US&hl=en";
// eltype is nececeary for the url aboth
// eltype is necessary for the url above
private static final String EL_INFO = "el=info";
public enum ItagType {
@@ -184,7 +184,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
// cached values
private static volatile String decryptionCode = "";
UrlIdHandler urlidhandler = new YoutubeStreamUrlIdHandler();
UrlIdHandler urlidhandler = YoutubeStreamUrlIdHandler.getInstance();
String pageUrl = "";
public YoutubeStreamExtractor(UrlIdHandler urlIdHandler, String pageUrl, int serviceId)
@@ -791,10 +791,15 @@ public class YoutubeStreamExtractor extends StreamExtractor {
try {
Downloader downloader = NewPipe.getDownloader();
if(!playerUrl.contains("https://youtube.com")) {
//sometimes the https://youtube.com part does not get send with
//than we have to add it by hand
playerUrl = "https://youtube.com" + playerUrl;
}
String playerCode = downloader.download(playerUrl);
decryptionFuncName =
Parser.matchGroup1("\\.sig\\|\\|([a-zA-Z0-9$]+)\\(", playerCode);
Parser.matchGroup("([\"\\'])signature\\1\\s*,\\s*([a-zA-Z0-9$]+)\\(", playerCode, 2);
String functionPattern = "("
+ decryptionFuncName.replace("$", "\\$")

View File

@@ -1,12 +1,21 @@
package org.schabi.newpipe.extractor.services.youtube;
import android.support.annotation.NonNull;
import org.schabi.newpipe.extractor.Downloader;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.Parser;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.util.regex.Matcher;
/**
* Created by Christian Schabesberger on 02.02.16.
@@ -29,45 +38,55 @@ import java.net.URLDecoder;
*/
public class YoutubeStreamUrlIdHandler implements UrlIdHandler {
@SuppressWarnings("WeakerAccess")
private static final YoutubeStreamUrlIdHandler instance = new YoutubeStreamUrlIdHandler();
private static final String ID_PATTERN = "([\\-a-zA-Z0-9_]{11})";
private YoutubeStreamUrlIdHandler() {}
public static YoutubeStreamUrlIdHandler getInstance() {
return instance;
}
@Override
public String getUrl(String videoId) {
return "https://www.youtube.com/watch?v=" + videoId;
}
@SuppressWarnings("WeakerAccess")
@Override
public String getId(String url) throws ParsingException, IllegalArgumentException {
if(url.isEmpty())
{
if(url.isEmpty()) {
throw new IllegalArgumentException("The url parameter should not be empty");
}
String id;
if(url.contains("youtube")) {
if(url.contains("attribution_link")) {
String id;
String lowercaseUrl = url.toLowerCase();
if(lowercaseUrl.contains("youtube")) {
if (url.contains("attribution_link")) {
try {
String escapedQuery = Parser.matchGroup1("u=(.[^&|$]*)", url);
String query = URLDecoder.decode(escapedQuery, "UTF-8");
id = Parser.matchGroup1("v=([\\-a-zA-Z0-9_]{11})", query);
} catch(UnsupportedEncodingException uee) {
id = Parser.matchGroup1("v=" + ID_PATTERN, query);
} catch (UnsupportedEncodingException uee) {
throw new ParsingException("Could not parse attribution_link", uee);
}
}
else if(url.contains("vnd.youtube"))
{
id = Parser.matchGroup1("([\\-a-zA-Z0-9_]{11}).*", url);
} else if(lowercaseUrl.contains("youtube.com/shared?ci=")) {
return getRealIdFromSharedLink(url);
} else if (url.contains("vnd.youtube")) {
id = Parser.matchGroup1(ID_PATTERN, url);
} else if (url.contains("embed")) {
id = Parser.matchGroup1("embed/" + ID_PATTERN, url);
} else if(url.contains("googleads")) {
throw new FoundAdException("Error found add: " + url);
} else {
id = Parser.matchGroup1("[?&]v=([\\-a-zA-Z0-9_]{11})", url);
id = Parser.matchGroup1("[?&]v=" + ID_PATTERN, url);
}
}
else if(url.contains("youtu.be")) {
else if(lowercaseUrl.contains("youtu.be")) {
if(url.contains("v=")) {
id = Parser.matchGroup1("v=([\\-a-zA-Z0-9_]{11})", url);
id = Parser.matchGroup1("v=" + ID_PATTERN, url);
} else {
id = Parser.matchGroup1("youtu\\.be/([a-zA-Z0-9_-]{11})", url);
id = Parser.matchGroup1("[Yy][Oo][Uu][Tt][Uu]\\.[Bb][Ee]/" + ID_PATTERN, url);
}
}
else {
@@ -82,12 +101,55 @@ public class YoutubeStreamUrlIdHandler implements UrlIdHandler {
}
}
/**
* Get the real url from a shared uri.
*
* Shared URI's look like this:
* <pre>
* * https://www.youtube.com/shared?ci=PJICrTByb3E
* * vnd.youtube://www.youtube.com/shared?ci=PJICrTByb3E&feature=twitter-deep-link
* </pre>
* @param url The shared url
* @return the id of the stream
* @throws ParsingException
*/
private @NonNull String getRealIdFromSharedLink(String url) throws ParsingException {
URI uri;
try {
uri = new URI(url);
} catch (URISyntaxException e) {
throw new ParsingException("Invalid shared link", e);
}
String sharedId = getSharedId(uri);
Downloader downloader = NewPipe.getDownloader();
String content;
try {
content = downloader.download("https://www.youtube.com/shared?ci=" + sharedId);
} catch (IOException | ReCaptchaException e) {
throw new ParsingException("Unable to resolve shared link", e);
}
// is this bad? is this fragile?:
String realId = Parser.matchGroup1("rel=\"shortlink\" href=\"https://youtu.be/" + ID_PATTERN, content);
if(sharedId.equals(realId)) {
throw new ParsingException("Got same id for as shared id: " + sharedId);
}
return realId;
}
private @NonNull String getSharedId(URI uri) throws ParsingException {
if (!"/shared".equals(uri.getPath())) {
throw new ParsingException("Not a shared link: " + uri.toString() + " (path != " + uri.getPath() + ")");
}
return Parser.matchGroup1("ci=" + ID_PATTERN, uri.getQuery());
}
public String cleanUrl(String complexUrl) throws ParsingException {
return getUrl(getId(complexUrl));
}
@Override
public boolean acceptUrl(String videoUrl) {
videoUrl = videoUrl.toLowerCase();
return videoUrl.contains("youtube") ||
videoUrl.contains("youtu.be");
}

View File

@@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor.stream_info;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
@@ -60,7 +61,7 @@ public class StreamPreviewInfoCollector {
if (urlIdHandler == null) {
throw new ParsingException("Error: UrlIdHandler not set");
} else if(!resultItem.webpage_url.isEmpty()) {
resultItem.id = (new YoutubeStreamUrlIdHandler()).getId(resultItem.webpage_url);
resultItem.id = NewPipe.getService(serviceId).getUrlIdHandlerInstance().getId(resultItem.webpage_url);
}
resultItem.title = extractor.getTitle();
resultItem.stream_type = extractor.getStreamType();

View File

@@ -30,13 +30,13 @@ import org.schabi.newpipe.R;
public class InfoItemHolder extends RecyclerView.ViewHolder {
public ImageView itemThumbnailView;
public TextView itemVideoTitleView,
public final ImageView itemThumbnailView;
public final TextView itemVideoTitleView,
itemUploaderView,
itemDurationView,
itemUploadDateView,
itemViewCountView;
public Button itemButton;
public final Button itemButton;
public InfoItemHolder(View v) {
super(v);
@@ -48,4 +48,5 @@ public class InfoItemHolder extends RecyclerView.ViewHolder {
itemViewCountView = (TextView) v.findViewById(R.id.itemViewCountView);
itemButton = (Button) v.findViewById(R.id.item_button);
}
}

View File

@@ -34,11 +34,12 @@ import java.util.Vector;
public class InfoListAdapter extends RecyclerView.Adapter<InfoItemHolder> {
InfoItemBuilder infoItemBuilder = null;
List<StreamPreviewInfo> streamList = new Vector<>();
private final InfoItemBuilder infoItemBuilder;
private final List<StreamPreviewInfo> streamList;
public InfoListAdapter(Activity a, View rootView) {
infoItemBuilder = new InfoItemBuilder(a, rootView);
streamList = new Vector<>();
}
public void setOnItemSelectedListener
@@ -54,7 +55,7 @@ public class InfoListAdapter extends RecyclerView.Adapter<InfoItemHolder> {
}
public void clearSteamItemList() {
streamList = new Vector<>();
streamList.clear();
notifyDataSetChanged();
}

View File

@@ -14,7 +14,6 @@ import android.preference.PreferenceManager;
import android.support.design.widget.Snackbar;
import android.support.v4.app.NavUtils;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
@@ -35,6 +34,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.ThemableActivity;
import org.schabi.newpipe.extractor.Parser;
import java.io.PrintWriter;
@@ -65,7 +65,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 ThemableActivity {
public static class ErrorInfo implements Parcelable {
public int userAction;
public String request;

View File

@@ -56,13 +56,15 @@ public class SearchInfoItemFragment extends Fragment {
private static final String TAG = SearchInfoItemFragment.class.toString();
/**
* Listener for search queries
*/
public class SearchQueryListener implements SearchView.OnQueryTextListener {
@Override
public boolean onQueryTextSubmit(String query) {
Activity a = getActivity();
try {
searchQuery = query;
search(query);
// hide virtual keyboard
@@ -89,8 +91,6 @@ public class SearchInfoItemFragment extends Fragment {
} catch (Exception e) {
e.printStackTrace();
}
View bg = a.findViewById(R.id.mainBG);
bg.setVisibility(View.GONE);
return true;
}
@@ -108,12 +108,10 @@ public class SearchInfoItemFragment extends Fragment {
private boolean isLoading = false;
private ProgressBar loadingIndicator = null;
private SearchView searchView = null;
private int pageNumber = 0;
private SuggestionListAdapter suggestionListAdapter = null;
private InfoListAdapter infoListAdapter = null;
private LinearLayoutManager streamInfoListLayoutManager = null;
private RecyclerView recyclerView = null;
// savedInstanceBundle arguments
private static final String QUERY = "query";
@@ -126,23 +124,32 @@ public class SearchInfoItemFragment extends Fragment {
public SearchInfoItemFragment() {
}
// TODO: Customize parameter initialization
@SuppressWarnings("unused")
public static SearchInfoItemFragment newInstance(int columnCount) {
public static SearchInfoItemFragment newInstance(int streamingServiceId, String searchQuery) {
Bundle args = new Bundle();
args.putInt(STREAMING_SERVICE, streamingServiceId);
args.putString(QUERY, searchQuery);
SearchInfoItemFragment fragment = new SearchInfoItemFragment();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
searchQuery = "";
if (savedInstanceState != null) {
searchQuery = savedInstanceState.getString(QUERY);
streamingServiceId = savedInstanceState.getInt(STREAMING_SERVICE);
} else {
try {
streamingServiceId = NewPipe.getIdOfService("Youtube");
Bundle args = getArguments();
if(args != null) {
searchQuery = args.getString(QUERY);
streamingServiceId = args.getInt(STREAMING_SERVICE);
} else {
streamingServiceId = NewPipe.getIdOfService("Youtube");
}
} catch (Exception e) {
e.printStackTrace();
ErrorActivity.reportError(getActivity(), e, null,
@@ -153,13 +160,14 @@ public class SearchInfoItemFragment extends Fragment {
}
}
setHasOptionsMenu(true);
SearchWorker sw = SearchWorker.getInstance();
sw.setSearchWorkerResultListener(new SearchWorker.SearchWorkerResultListener() {
@Override
public void onResult(SearchResult result) {
infoListAdapter.addStreamItemList(result.resultList);
isLoading = false;
loadingIndicator.setVisibility(View.GONE);
setDoneLoading();
}
@Override
@@ -167,8 +175,7 @@ public class SearchInfoItemFragment extends Fragment {
//setListShown(true);
Toast.makeText(getActivity(), getString(stringResource),
Toast.LENGTH_SHORT).show();
isLoading = false;
loadingIndicator.setVisibility(View.GONE);
setDoneLoading();
}
@Override
@@ -176,8 +183,7 @@ public class SearchInfoItemFragment extends Fragment {
//setListShown(true);
Toast.makeText(getActivity(), message,
Toast.LENGTH_LONG).show();
isLoading = false;
loadingIndicator.setVisibility(View.GONE);
setDoneLoading();
}
@Override
@@ -191,6 +197,7 @@ public class SearchInfoItemFragment extends Fragment {
RECAPTCHA_REQUEST);
}
});
}
@Override
@@ -200,7 +207,7 @@ public class SearchInfoItemFragment extends Fragment {
Context context = view.getContext();
loadingIndicator = (ProgressBar) view.findViewById(R.id.progressBar);
recyclerView = (RecyclerView) view.findViewById(R.id.list);
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list);
streamInfoListLayoutManager = new LinearLayoutManager(context);
recyclerView.setLayoutManager(streamInfoListLayoutManager);
@@ -209,15 +216,12 @@ public class SearchInfoItemFragment extends Fragment {
infoListAdapter.setOnItemSelectedListener(new InfoItemBuilder.OnItemSelectedListener() {
@Override
public void selected(String url) {
Intent i = new Intent(getActivity(), VideoItemDetailActivity.class);
i.putExtra(VideoItemDetailFragment.STREAMING_SERVICE, streamingServiceId);
i.putExtra(VideoItemDetailFragment.VIDEO_URL, url);
getActivity().startActivity(i);
startDetailActivity(url);
}
});
recyclerView.setAdapter(infoListAdapter);
recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
recyclerView.clearOnScrollListeners();
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
int pastVisiblesItems, visibleItemCount, totalItemCount;
@@ -239,14 +243,26 @@ public class SearchInfoItemFragment extends Fragment {
return view;
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
private void startDetailActivity(String url) {
Intent i = new Intent(getActivity(), VideoItemDetailActivity.class);
i.putExtra(VideoItemDetailFragment.STREAMING_SERVICE, streamingServiceId);
i.putExtra(VideoItemDetailFragment.VIDEO_URL, url);
getActivity().startActivity(i);
}
@Override
public void onDetach() {
super.onDetach();
public void onStart() {
super.onStart();
if(!searchQuery.isEmpty()) {
search(searchQuery);
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(QUERY, searchQuery);
outState.putInt(STREAMING_SERVICE, streamingServiceId);
}
@Override
@@ -255,15 +271,10 @@ public class SearchInfoItemFragment extends Fragment {
inflater.inflate(R.menu.search_menu, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
searchView = (SearchView) searchItem.getActionView();
SearchView searchView = (SearchView) searchItem.getActionView();
setupSearchView(searchView);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
private void setupSearchView(SearchView searchView) {
suggestionListAdapter = new SuggestionListAdapter(getActivity());
searchView.setSuggestionsAdapter(suggestionListAdapter);
@@ -278,7 +289,9 @@ public class SearchInfoItemFragment extends Fragment {
private void search(String query) {
infoListAdapter.clearSteamItemList();
pageNumber = 0;
searchQuery = query;
search(query, pageNumber);
hideBackground();
loadingIndicator.setVisibility(View.VISIBLE);
}
@@ -288,6 +301,20 @@ public class SearchInfoItemFragment extends Fragment {
sw.search(streamingServiceId, query, page, getActivity());
}
private void setDoneLoading() {
this.isLoading = false;
loadingIndicator.setVisibility(View.GONE);
}
/**
* Hides the "dummy" background when no results are shown
*/
private void hideBackground() {
View view = getView();
if(view == null) return;
view.findViewById(R.id.mainBG).setVisibility(View.GONE);
}
private void searchSuggestions(String query) {
SuggestionSearchRunnable suggestionSearchRunnable =
new SuggestionSearchRunnable(streamingServiceId, query, getActivity(), suggestionListAdapter);

View File

@@ -25,8 +25,8 @@ import android.support.v7.widget.SearchView;
public class SearchSuggestionListener implements SearchView.OnSuggestionListener{
private SearchView searchView;
private SuggestionListAdapter adapter;
private final SearchView searchView;
private final SuggestionListAdapter adapter;
public SearchSuggestionListener(SearchView searchView, SuggestionListAdapter adapter) {
this.searchView = searchView;

View File

@@ -82,6 +82,7 @@ public class SearchWorker {
}
@Override
public void run() {
final String serviceName = NewPipe.getNameOfService(serviceId);
SearchResult result = null;
SearchEngine engine = null;
@@ -119,7 +120,7 @@ public class SearchWorker {
View rootView = a.findViewById(android.R.id.content);
ErrorActivity.reportError(h, a, result.errors, null, rootView,
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
/* todo: this shoudl not be assigned static */ YOUTUBE, query, R.string.light_parsing_error));
serviceName, query, R.string.light_parsing_error));
}
// hard errors:
@@ -148,8 +149,7 @@ public class SearchWorker {
} catch(ExtractionException e) {
ErrorActivity.reportError(h, a, e, null, null,
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
/* todo: this shoudl not be assigned static */
YOUTUBE, query, R.string.parsing_error));
serviceName, query, R.string.parsing_error));
//postNewErrorToast(h, R.string.parsing_error);
e.printStackTrace();

View File

@@ -3,10 +3,8 @@ package org.schabi.newpipe.search_fragment;
import android.content.Context;
import android.database.Cursor;
import android.database.MatrixCursor;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.support.v4.widget.ResourceCursorAdapter;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.List;
@@ -31,52 +29,56 @@ import java.util.List;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/
public class SuggestionListAdapter extends CursorAdapter {
/**
* {@link ResourceCursorAdapter} to display suggestions.
*/
public class SuggestionListAdapter extends ResourceCursorAdapter {
private static final String[] columns = new String[]{"_id", "title"};
private static final int INDEX_ID = 0;
private static final int INDEX_TITLE = 1;
private String[] columns = new String[]{"_id", "title"};
public SuggestionListAdapter(Context context) {
super(context, null, false);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
ViewHolder viewHolder;
View view = LayoutInflater.from(context).inflate(android.R.layout.simple_list_item_1, parent, false);
viewHolder = new ViewHolder();
viewHolder.suggestionTitle = (TextView) view.findViewById(android.R.id.text1);
view.setTag(viewHolder);
return view;
super(context, android.R.layout.simple_list_item_1, null, 0);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
ViewHolder viewHolder = (ViewHolder) view.getTag();
viewHolder.suggestionTitle.setText(cursor.getString(1));
ViewHolder viewHolder = new ViewHolder(view);
viewHolder.suggestionTitle.setText(cursor.getString(INDEX_TITLE));
}
/**
* Update the suggestion list
* @param suggestions the list of suggestions
*/
public void updateAdapter(List<String> suggestions) {
MatrixCursor cursor = new MatrixCursor(columns);
MatrixCursor cursor = new MatrixCursor(columns, suggestions.size());
int i = 0;
for (String s : suggestions) {
String[] temp = new String[2];
temp[0] = Integer.toString(i);
temp[1] = s;
for (String suggestion : suggestions) {
String[] columnValues = new String[columns.length];
columnValues[INDEX_TITLE] = suggestion;
columnValues[INDEX_ID] = Integer.toString(i);
cursor.addRow(columnValues);
i++;
cursor.addRow(temp);
}
changeCursor(cursor);
}
/**
* Get the suggestion for a position
* @param position the position of the suggestion
* @return the suggestion
*/
public String getSuggestion(int position) {
return ((Cursor) getItem(position)).getString(1);
return ((Cursor) getItem(position)).getString(INDEX_TITLE);
}
private class ViewHolder {
public TextView suggestionTitle;
private final TextView suggestionTitle;
private ViewHolder(View view) {
this.suggestionTitle = (TextView) view.findViewById(android.R.id.text1);
}
}
}

View File

@@ -37,14 +37,15 @@ import java.util.List;
public class SuggestionSearchRunnable implements Runnable{
/**
* Runnable to update a {@link SuggestionListAdapter}
*/
private class SuggestionResultRunnable implements Runnable{
private List<String> suggestions;
private SuggestionListAdapter adapter;
private final List<String> suggestions;
private SuggestionResultRunnable(List<String> suggestions, SuggestionListAdapter adapter) {
private SuggestionResultRunnable(List<String> suggestions) {
this.suggestions = suggestions;
this.adapter = adapter;
}
@Override
@@ -55,9 +56,9 @@ public class SuggestionSearchRunnable implements Runnable{
private final int serviceId;
private final String query;
final Handler h = new Handler();
private Activity a = null;
private SuggestionListAdapter adapter;
private final Handler h = new Handler();
private final Activity a;
private final SuggestionListAdapter adapter;
public SuggestionSearchRunnable(int serviceId, String query,
Activity activity, SuggestionListAdapter adapter) {
this.serviceId = serviceId;
@@ -76,7 +77,7 @@ public class SuggestionSearchRunnable implements Runnable{
String searchLanguage = sp.getString(searchLanguageKey,
a.getString(R.string.default_language_value));
List<String> suggestions = se.suggestionList(query, searchLanguage);
h.post(new SuggestionResultRunnable(suggestions, adapter));
h.post(new SuggestionResultRunnable(suggestions));
} catch (ExtractionException e) {
ErrorActivity.reportError(h, a, e, null, a.findViewById(android.R.id.content),
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,

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,11 @@ public class SettingsActivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceBundle) {
if (PreferenceManager.getDefaultSharedPreferences(this)
.getString("theme", getResources().getString(R.string.light_theme_title)).
equals(getResources().getString(R.string.dark_theme_title))) {
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;
@@ -20,6 +21,7 @@ import org.schabi.newpipe.App;
import org.schabi.newpipe.R;
import java.util.ArrayList;
import java.util.Objects;
import info.guardianproject.netcipher.proxy.OrbotHelper;
@@ -55,6 +57,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 +66,11 @@ 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

@@ -0,0 +1,68 @@
package org.schabi.newpipe.util;
import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
public class PermissionHelper {
public static final int PERMISSION_WRITE_STORAGE = 778;
public static final int PERMISSION_READ_STORAGE = 777;
public static boolean checkStoragePermissions(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
if(!checkReadStoragePermissions(activity)) return false;
}
return checkWriteStoragePermissions(activity);
}
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
public static boolean checkReadStoragePermissions(Activity activity) {
if (ContextCompat.checkSelfPermission(activity, Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(activity,
new String[]{
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE},
PERMISSION_READ_STORAGE);
return false;
}
return true;
}
public static boolean checkWriteStoragePermissions(Activity activity) {
// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(activity,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
/*if (ActivityCompat.shouldShowRequestPermissionRationale(activity,
Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {*/
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(activity,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
PERMISSION_WRITE_STORAGE);
// PERMISSION_WRITE_STORAGE is an
// app-defined int constant. The callback method gets the
// result of the request.
/*}*/
return false;
}
return true;
}
}

View File

@@ -0,0 +1,36 @@
package us.shandian.giga.get;
import java.util.List;
/**
* Provides access to the storage of {@link DownloadMission}s
*/
public interface DownloadDataSource {
/**
* Load all missions
* @return a list of download missions
*/
List<DownloadMission> loadMissions();
/**
* Add a downlaod mission to the storage
* @param downloadMission the download mission to add
* @return the identifier of the mission
*/
void addMission(DownloadMission downloadMission);
/**
* Update a download mission which exists in the storage
* @param downloadMission the download mission to update
* @throws IllegalArgumentException if the mission was not added to storage
*/
void updateMission(DownloadMission downloadMission);
/**
* Delete a download mission
* @param downloadMission the mission to delete
*/
void deleteMission(DownloadMission downloadMission);
}

Some files were not shown because too many files have changed in this diff Show More