kopia lustrzana https://github.com/TeamNewPipe/NewPipe
Merge remote-tracking branch 'origin/master'
commit
cca72a9e4e
|
@ -8,8 +8,8 @@ android {
|
|||
applicationId "org.schabi.newpipe"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 23
|
||||
versionCode 16
|
||||
versionName "0.7.7"
|
||||
versionCode 17
|
||||
versionName "0.7.8"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
|
@ -42,6 +42,5 @@ dependencies {
|
|||
compile 'de.hdodenhof:circleimageview:2.0.0'
|
||||
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
|
||||
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'
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class App extends Application {
|
|||
/**
|
||||
* 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;
|
||||
if (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) {
|
||||
OrbotHelper.requestStartTor(context);
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isUsingTor() {
|
||||
public static boolean isUsingTor() {
|
||||
return useTor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.design.widget.Snackbar;
|
||||
|
@ -23,13 +22,13 @@ import android.view.View;
|
|||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.schabi.newpipe.extractor.Parser;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -237,12 +236,19 @@ public class ErrorActivity extends AppCompatActivity {
|
|||
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) {
|
||||
String text = "";
|
||||
if(el != null) {
|
||||
for (Exception e : el) {
|
||||
text += "-------------------------------------\n"
|
||||
+ ExceptionUtils.getStackTrace(e);
|
||||
+ getStackTrace(e);
|
||||
}
|
||||
}
|
||||
text += "-------------------------------------";
|
||||
|
@ -299,7 +305,7 @@ public class ErrorActivity extends AppCompatActivity {
|
|||
JSONArray exceptionArray = new JSONArray();
|
||||
if(errorList != null) {
|
||||
for (Exception e : errorList) {
|
||||
exceptionArray.put(ExceptionUtils.getStackTrace(e));
|
||||
exceptionArray.put(getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import android.content.SharedPreferences;
|
|||
import android.os.Environment;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
@ -43,10 +42,6 @@ public class NewPipeSettings {
|
|||
getAudioDownloadFolder(context);
|
||||
}
|
||||
|
||||
public static File getDownloadFolder() {
|
||||
return getFolder(Environment.DIRECTORY_DOWNLOADS);
|
||||
}
|
||||
|
||||
public static File getVideoDownloadFolder(Context context) {
|
||||
return getFolder(context, R.string.download_path_key, Environment.DIRECTORY_MOVIES);
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ import java.util.ArrayList;
|
|||
import java.util.Vector;
|
||||
|
||||
|
||||
import org.schabi.newpipe.download.DownloadDialog;
|
||||
import org.schabi.newpipe.extractor.AudioStream;
|
||||
import org.schabi.newpipe.extractor.MediaFormat;
|
||||
import org.schabi.newpipe.extractor.ParsingException;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.schabi.newpipe;
|
||||
package org.schabi.newpipe.download;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Dialog;
|
||||
|
@ -16,6 +16,10 @@ import android.support.v7.app.AlertDialog;
|
|||
import android.util.Log;
|
||||
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.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -71,7 +75,8 @@ public class DownloadDialog extends DialogFragment {
|
|||
case 0: // Video
|
||||
download(arguments.getString(VIDEO_URL),
|
||||
title,
|
||||
arguments.getString(FILE_SUFFIX_VIDEO), context);
|
||||
arguments.getString(FILE_SUFFIX_VIDEO),
|
||||
NewPipeSettings.getVideoDownloadFolder(context),context);
|
||||
break;
|
||||
default:
|
||||
Log.d(TAG, "lolz");
|
||||
|
@ -89,7 +94,8 @@ public class DownloadDialog extends DialogFragment {
|
|||
case 0: // Audio
|
||||
download(arguments.getString(AUDIO_URL),
|
||||
title,
|
||||
arguments.getString(FILE_SUFFIX_AUDIO), context);
|
||||
arguments.getString(FILE_SUFFIX_AUDIO),
|
||||
NewPipeSettings.getAudioDownloadFolder(context),context);
|
||||
break;
|
||||
default:
|
||||
Log.d(TAG, "lolz");
|
||||
|
@ -107,12 +113,14 @@ public class DownloadDialog extends DialogFragment {
|
|||
case 0: // Video
|
||||
download(arguments.getString(VIDEO_URL),
|
||||
title,
|
||||
arguments.getString(FILE_SUFFIX_VIDEO), context);
|
||||
arguments.getString(FILE_SUFFIX_VIDEO),
|
||||
NewPipeSettings.getVideoDownloadFolder(context), context);
|
||||
break;
|
||||
case 1:
|
||||
download(arguments.getString(AUDIO_URL),
|
||||
title,
|
||||
arguments.getString(FILE_SUFFIX_AUDIO), context);
|
||||
arguments.getString(FILE_SUFFIX_AUDIO),
|
||||
NewPipeSettings.getAudioDownloadFolder(context), context);
|
||||
break;
|
||||
default:
|
||||
Log.d(TAG, "lolz");
|
||||
|
@ -141,8 +149,8 @@ public class DownloadDialog extends DialogFragment {
|
|||
return nameToTest;
|
||||
}
|
||||
|
||||
private void download(String url, String title, String fileSuffix, Context context) {
|
||||
File downloadDir = NewPipeSettings.getDownloadFolder();
|
||||
private void download(String url, String title,
|
||||
String fileSuffix, File downloadDir, Context context) {
|
||||
|
||||
if(!downloadDir.exists()) {
|
||||
//attempt to create directory
|
||||
|
@ -162,6 +170,8 @@ public class DownloadDialog extends DialogFragment {
|
|||
File saveFilePath = new File(downloadDir,createFileName(title) + fileSuffix);
|
||||
|
||||
long id = 0;
|
||||
|
||||
|
||||
if (App.isUsingTor()) {
|
||||
// if using Tor, do not use DownloadManager because the proxy cannot be set
|
||||
FileDownloader.downloadFile(getContext(), url, saveFilePath, title);
|
|
@ -1,26 +1,21 @@
|
|||
package org.schabi.newpipe;
|
||||
|
||||
package org.schabi.newpipe.download;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.util.Log;
|
||||
|
||||
import org.schabi.newpipe.R;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
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/>.
|
||||
*/
|
||||
|
||||
|
||||
// TODO: FOR HEVEN 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";
|
||||
|
||||
|
@ -165,5 +162,4 @@ public class FileDownloader extends AsyncTask<Void, Integer, Void> {
|
|||
super.onPostExecute(aVoid);
|
||||
nm.cancel(notifyId);
|
||||
}
|
||||
|
||||
}
|
Ładowanie…
Reference in New Issue