1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-24 17:10:33 +00:00

Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-03-25 18:58:08 +01:00
commit cca72a9e4e
7 changed files with 39 additions and 32 deletions

View File

@ -8,8 +8,8 @@ android {
applicationId "org.schabi.newpipe" applicationId "org.schabi.newpipe"
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 23 targetSdkVersion 23
versionCode 16 versionCode 17
versionName "0.7.7" versionName "0.7.8"
} }
buildTypes { buildTypes {
release { release {
@ -42,6 +42,5 @@ dependencies {
compile 'de.hdodenhof:circleimageview:2.0.0' compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.github.nirhart:parallaxscroll:1.0' compile 'com.github.nirhart:parallaxscroll:1.0'
compile 'org.apache.directory.studio:org.apache.commons.lang:2.6'
compile 'com.google.android.exoplayer:exoplayer:r1.5.5' compile 'com.google.android.exoplayer:exoplayer:r1.5.5'
} }

View File

@ -57,7 +57,7 @@ public class App extends Application {
/** /**
* Set the proxy settings based on whether Tor should be enabled or not. * Set the proxy settings based on whether Tor should be enabled or not.
*/ */
static void configureTor(boolean enabled) { public static void configureTor(boolean enabled) {
useTor = enabled; useTor = enabled;
if (useTor) { if (useTor) {
NetCipher.useTor(); NetCipher.useTor();
@ -66,13 +66,13 @@ public class App extends Application {
} }
} }
static void checkStartTor(Context context) { public static void checkStartTor(Context context) {
if (useTor) { if (useTor) {
OrbotHelper.requestStartTor(context); OrbotHelper.requestStartTor(context);
} }
} }
static boolean isUsingTor() { public static boolean isUsingTor() {
return useTor; return useTor;
} }
} }

View File

@ -7,7 +7,6 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
@ -23,13 +22,13 @@ import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import org.schabi.newpipe.extractor.Parser; import org.schabi.newpipe.extractor.Parser;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -237,12 +236,19 @@ public class ErrorActivity extends AppCompatActivity {
return false; return false;
} }
private static String getStackTrace(final Throwable throwable) {
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw, true);
throwable.printStackTrace(pw);
return sw.getBuffer().toString();
}
private String formErrorText(List<Exception> el) { private String formErrorText(List<Exception> el) {
String text = ""; String text = "";
if(el != null) { if(el != null) {
for (Exception e : el) { for (Exception e : el) {
text += "-------------------------------------\n" text += "-------------------------------------\n"
+ ExceptionUtils.getStackTrace(e); + getStackTrace(e);
} }
} }
text += "-------------------------------------"; text += "-------------------------------------";
@ -299,7 +305,7 @@ public class ErrorActivity extends AppCompatActivity {
JSONArray exceptionArray = new JSONArray(); JSONArray exceptionArray = new JSONArray();
if(errorList != null) { if(errorList != null) {
for (Exception e : errorList) { for (Exception e : errorList) {
exceptionArray.put(ExceptionUtils.getStackTrace(e)); exceptionArray.put(getStackTrace(e));
} }
} }

View File

@ -25,7 +25,6 @@ import android.content.SharedPreferences;
import android.os.Environment; import android.os.Environment;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.util.Log;
import java.io.File; import java.io.File;
@ -43,10 +42,6 @@ public class NewPipeSettings {
getAudioDownloadFolder(context); getAudioDownloadFolder(context);
} }
public static File getDownloadFolder() {
return getFolder(Environment.DIRECTORY_DOWNLOADS);
}
public static File getVideoDownloadFolder(Context context) { public static File getVideoDownloadFolder(Context context) {
return getFolder(context, R.string.download_path_key, Environment.DIRECTORY_MOVIES); return getFolder(context, R.string.download_path_key, Environment.DIRECTORY_MOVIES);
} }

View File

@ -48,6 +48,7 @@ import java.util.ArrayList;
import java.util.Vector; import java.util.Vector;
import org.schabi.newpipe.download.DownloadDialog;
import org.schabi.newpipe.extractor.AudioStream; import org.schabi.newpipe.extractor.AudioStream;
import org.schabi.newpipe.extractor.MediaFormat; import org.schabi.newpipe.extractor.MediaFormat;
import org.schabi.newpipe.extractor.ParsingException; import org.schabi.newpipe.extractor.ParsingException;

View File

@ -1,4 +1,4 @@
package org.schabi.newpipe; package org.schabi.newpipe.download;
import android.Manifest; import android.Manifest;
import android.app.Dialog; import android.app.Dialog;
@ -16,6 +16,10 @@ import android.support.v7.app.AlertDialog;
import android.util.Log; import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
import org.schabi.newpipe.App;
import org.schabi.newpipe.NewPipeSettings;
import org.schabi.newpipe.R;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -71,7 +75,8 @@ public class DownloadDialog extends DialogFragment {
case 0: // Video case 0: // Video
download(arguments.getString(VIDEO_URL), download(arguments.getString(VIDEO_URL),
title, title,
arguments.getString(FILE_SUFFIX_VIDEO), context); arguments.getString(FILE_SUFFIX_VIDEO),
NewPipeSettings.getVideoDownloadFolder(context),context);
break; break;
default: default:
Log.d(TAG, "lolz"); Log.d(TAG, "lolz");
@ -89,7 +94,8 @@ public class DownloadDialog extends DialogFragment {
case 0: // Audio case 0: // Audio
download(arguments.getString(AUDIO_URL), download(arguments.getString(AUDIO_URL),
title, title,
arguments.getString(FILE_SUFFIX_AUDIO), context); arguments.getString(FILE_SUFFIX_AUDIO),
NewPipeSettings.getAudioDownloadFolder(context),context);
break; break;
default: default:
Log.d(TAG, "lolz"); Log.d(TAG, "lolz");
@ -107,12 +113,14 @@ public class DownloadDialog extends DialogFragment {
case 0: // Video case 0: // Video
download(arguments.getString(VIDEO_URL), download(arguments.getString(VIDEO_URL),
title, title,
arguments.getString(FILE_SUFFIX_VIDEO), context); arguments.getString(FILE_SUFFIX_VIDEO),
NewPipeSettings.getVideoDownloadFolder(context), context);
break; break;
case 1: case 1:
download(arguments.getString(AUDIO_URL), download(arguments.getString(AUDIO_URL),
title, title,
arguments.getString(FILE_SUFFIX_AUDIO), context); arguments.getString(FILE_SUFFIX_AUDIO),
NewPipeSettings.getAudioDownloadFolder(context), context);
break; break;
default: default:
Log.d(TAG, "lolz"); Log.d(TAG, "lolz");
@ -141,8 +149,8 @@ public class DownloadDialog extends DialogFragment {
return nameToTest; return nameToTest;
} }
private void download(String url, String title, String fileSuffix, Context context) { private void download(String url, String title,
File downloadDir = NewPipeSettings.getDownloadFolder(); String fileSuffix, File downloadDir, Context context) {
if(!downloadDir.exists()) { if(!downloadDir.exists()) {
//attempt to create directory //attempt to create directory
@ -162,6 +170,8 @@ public class DownloadDialog extends DialogFragment {
File saveFilePath = new File(downloadDir,createFileName(title) + fileSuffix); File saveFilePath = new File(downloadDir,createFileName(title) + fileSuffix);
long id = 0; long id = 0;
if (App.isUsingTor()) { if (App.isUsingTor()) {
// if using Tor, do not use DownloadManager because the proxy cannot be set // if using Tor, do not use DownloadManager because the proxy cannot be set
FileDownloader.downloadFile(getContext(), url, saveFilePath, title); FileDownloader.downloadFile(getContext(), url, saveFilePath, title);

View File

@ -1,26 +1,21 @@
package org.schabi.newpipe; package org.schabi.newpipe.download;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
import android.util.Log; import android.util.Log;
import org.schabi.newpipe.R;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL;
import java.net.UnknownHostException;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
@ -46,6 +41,8 @@ import info.guardianproject.netcipher.NetCipher;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>. * along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/ */
// TODO: FOR HEVEN SAKE !!! DO NOT SIMPLY USE ASYNCTASK. MAKE THIS A PROPER SERVICE !!!
public class FileDownloader extends AsyncTask<Void, Integer, Void> { public class FileDownloader extends AsyncTask<Void, Integer, Void> {
public static final String TAG = "FileDownloader"; public static final String TAG = "FileDownloader";
@ -165,5 +162,4 @@ public class FileDownloader extends AsyncTask<Void, Integer, Void> {
super.onPostExecute(aVoid); super.onPostExecute(aVoid);
nm.cancel(notifyId); nm.cancel(notifyId);
} }
} }