Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.17.1 #2530

Merged
merged 143 commits into from
Aug 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
6908355
Translated using Weblate (Turkish)
Jun 4, 2019
99ad3dc
Translated using Weblate (Czech)
Jun 3, 2019
8cbfe9e
Translated using Weblate (Polish)
Jun 2, 2019
50e8f45
Translated using Weblate (Italian)
pjammo Jun 4, 2019
ffed9f6
Translated using Weblate (Arabic)
BoFFire Jun 3, 2019
8842f53
Translated using Weblate (Spanish)
idetedi Jun 3, 2019
bd55b91
Translated using Weblate (French)
jazzzz Jun 3, 2019
691c1e1
Translated using Weblate (Chinese (Traditional))
s8321414 Jun 4, 2019
4844037
Merge branch 'origin/dev' into Weblate.
weblate Jun 4, 2019
d153772
Translated using Weblate (Russian)
Jun 4, 2019
a92bf15
Translated using Weblate (Russian)
Jun 4, 2019
4ca6393
Translated using Weblate (Russian)
Jun 4, 2019
daf2890
Added translation using Weblate (Nepali)
prashant-shahi Jun 5, 2019
ff430f5
Translated using Weblate (German)
nautilusx Jun 4, 2019
3ddc3ac
Translated using Weblate (German)
SantosSi Jun 5, 2019
f8784ae
Translated using Weblate (Czech)
auzkok Jun 11, 2019
7ca0263
Translated using Weblate (Czech)
Jun 11, 2019
b1f27b9
Translated using Weblate (Spanish)
Jun 10, 2019
3952c88
Translated using Weblate (Portuguese (Brazil))
gabriellluz Jun 5, 2019
08bc975
Translated using Weblate (Greek)
Jun 5, 2019
b4ef44b
Translated using Weblate (Greek)
Jun 8, 2019
a4274c6
Translated using Weblate (Ukrainian)
Jun 5, 2019
59085ff
Translated using Weblate (Japanese)
naofum Jun 8, 2019
b6e4afe
Translated using Weblate (Catalan)
marcriera Jun 5, 2019
630cbc7
Translated using Weblate (Portuguese)
SantosSi Jun 5, 2019
1961179
Translated using Weblate (Croatian)
Stipess1 Jun 5, 2019
90c525e
Translated using Weblate (Hebrew)
yarons Jun 4, 2019
429a9a4
Translated using Weblate (Polish)
Jun 6, 2019
472fd72
Translated using Weblate (Italian)
pjammo Jun 5, 2019
21eff0b
Translated using Weblate (Italian)
airon90 Jun 7, 2019
25c3669
Translated using Weblate (Arabic)
BoFFire Jun 4, 2019
cc89a34
Translated using Weblate (Arabic)
Jun 5, 2019
a14033a
Translated using Weblate (Indonesian)
Jun 10, 2019
086cceb
Translated using Weblate (Dutch)
Jun 5, 2019
be42393
Translated using Weblate (Nepali)
prashant-shahi Jun 5, 2019
7971785
Translated using Weblate (French)
Floflr Jun 4, 2019
2a57d74
Translated using Weblate (French)
Jun 4, 2019
3c0d7de
Translated using Weblate (Flemish)
Jun 5, 2019
f1f9147
Translated using Weblate (Chinese (Traditional))
s8321414 Jun 4, 2019
a15ef4b
Translated using Weblate (Norwegian Bokmål)
comradekingu Jun 4, 2019
04a5f43
Merge branch 'origin/dev' into Weblate.
weblate Jun 13, 2019
5252834
Translated using Weblate (Spanish)
j9o1 Jun 14, 2019
9c2cf9e
Translated using Weblate (Belarusian)
Jun 16, 2019
1f2cd06
Translated using Weblate (Portuguese (Brazil))
edcaron Jun 19, 2019
e99266f
Translated using Weblate (Italian)
airon90 Jun 20, 2019
1d1cee1
Translated using Weblate (Turkish)
GokhanBT Jun 22, 2019
6cbb8b1
Translated using Weblate (Turkish)
Jun 26, 2019
3715326
Translated using Weblate (Arabic)
Jun 26, 2019
2b2ee56
Translated using Weblate (Spanish)
j9o1 Jun 27, 2019
6f97819
Translated using Weblate (Turkish)
MehmetaliKuran Jul 1, 2019
372d5ce
Translated using Weblate (Basque)
osoitz Jun 30, 2019
200a81d
Translated using Weblate (Tamil)
khaleeljageer Jul 2, 2019
daecfd9
Translated using Weblate (Greek)
Jul 3, 2019
ee3ec3a
Translated using Weblate (French)
Jul 3, 2019
2d6362d
Translated using Weblate (Bulgarian)
maturabg Jul 5, 2019
8fcd236
Translated using Weblate (Italian)
Jul 8, 2019
550c74d
Translated using Weblate (Croatian)
Jul 9, 2019
1b66ffa
Translated using Weblate (Norwegian Bokmål)
7RST1 Jul 10, 2019
632e52b
Translated using Weblate (Norwegian Bokmål)
comradekingu Jul 10, 2019
99c519c
Translated using Weblate (Russian)
Jul 13, 2019
b83a1fd
Translated using Weblate (Korean)
blue-pencil Jul 16, 2019
77db3cb
Translated using Weblate (Persian)
ahangarha Jul 17, 2019
3f790d0
Translated using Weblate (Korean)
blue-pencil Jul 23, 2019
d4ecd0d
Translated using Weblate (Korean)
ogaskr Jul 23, 2019
4c92aeb
Translated using Weblate (Korean)
ogaskr Jul 23, 2019
2a44a09
Translated using Weblate (Korean)
hatsunearu Jul 23, 2019
8cc8aa8
Translated using Weblate (Serbian)
emv412 Aug 1, 2019
12c9dbf
Translated using Weblate (Esperanto)
BastogneBas Jul 31, 2019
ef9044d
Translated using Weblate (Catalan)
marcriera Jul 23, 2019
a60a9bb
Translated using Weblate (Russian)
Aug 2, 2019
5a6a6bc
clean-up: remove unused method
kapodamy Aug 1, 2019
0375194
fix start/pause buttons disappear when screen goes off
kapodamy Aug 1, 2019
2328ea6
dont hardcode the buttons
kapodamy Aug 3, 2019
35a69b4
update download_menu.xml
kapodamy Aug 10, 2019
c02383d
Merge branch 'dev' into buttons-hiding-fix-on-screen-off
TobiGr Aug 12, 2019
5883f6e
Merge pull request #2487 from kapodamy/buttons-hiding-fix-on-screen-off
TobiGr Aug 12, 2019
5254e85
Added translation using Weblate (Thai)
kowith337 Aug 12, 2019
c46af7d
Merge branch 'weblate' into dev
TobiGr Aug 12, 2019
ec3ae7c
Clean up string resources
TobiGr Aug 12, 2019
8de5c53
Fix typo in HistorySettinsFragment
TobiGr Aug 13, 2019
5053d47
Do not save playback position when watch history is disabled
TobiGr Aug 13, 2019
1b0a958
Create FUNDING.yml
superusercode Aug 14, 2019
e6617ff
Fix slowdowns in stream list views
Stypox Aug 14, 2019
04e725b
Fix some inspection warnings in modified files
Stypox Aug 14, 2019
00fc521
Fix potential disposable leak in PlaylistAppendDialog
Stypox Aug 14, 2019
7da827a
Fix annotation warnings
Stypox Aug 14, 2019
63301ee
Remove "Trollolo" logs
Stypox Aug 14, 2019
ebf91d2
Clean up code for addItems() on ItemListAdapters.
Stypox Aug 14, 2019
c190dc4
Fix annotation warnings in modified files
Stypox Aug 14, 2019
c96a05a
Customize "start here" actions in playlist item views
Stypox Aug 14, 2019
0dc71ce
Merge pull request #2517 from Stypox/list-slowdown-fix
theScrabi Aug 14, 2019
6133c97
Merge branch 'dev' into playlist-play-from-here
theScrabi Aug 14, 2019
f66c2ba
Merge pull request #2518 from Stypox/playlist-play-from-here
theScrabi Aug 14, 2019
6457cac
Merge branch 'dev' into patch-1
superusercode Aug 14, 2019
6521845
check for Storage Access Framework features
kapodamy Aug 14, 2019
950cf71
use legacy file picker in those cases where saf is not available
kapodamy Aug 15, 2019
dee3a18
misc changes
kapodamy Aug 15, 2019
45ad862
Translated using Weblate (Thai)
kowith337 Aug 12, 2019
14db8b1
Translated using Weblate (Arabic)
Aug 14, 2019
b697e05
Merge branch 'origin/dev' into Weblate.
weblate Aug 15, 2019
fffeadd
Translated using Weblate (German)
nautilusx Aug 15, 2019
6a0450b
Merge pull request #2516 from rogersachan/patch-1
theScrabi Aug 15, 2019
93dff5c
Merge branch 'dev' into saf-workarround
theScrabi Aug 15, 2019
8f13a7e
check if the if the content provider is disabled (the app itself)
kapodamy Aug 16, 2019
1ba7710
Merge remote-tracking branch 'origin/saf-workarround' into saf-workar…
kapodamy Aug 16, 2019
63def07
Add url to recaptcha exceptions, after update in extractor
Stypox Aug 17, 2019
e66f2ab
Fix ReCaptchaActivity layout crash due to hidden EditText
Stypox Aug 17, 2019
43446d5
Load the url from the exception in the ReCaptchaActivity
Stypox Aug 17, 2019
10dfcbf
add manual switch in download setting fragment
kapodamy Aug 17, 2019
c89f0e5
Merge pull request #2527 from Stypox/recaptcha-with-url
theScrabi Aug 17, 2019
c01609b
Merge branch 'dev' into saf-workarround
theScrabi Aug 17, 2019
96baa29
Merge pull request #2521 from kapodamy/saf-workarround
theScrabi Aug 17, 2019
88ebd96
Merge remote-tracking branch 'Weblate/dev' into dev
TobiGr Aug 17, 2019
b992add
move on to version 0.17.1
theScrabi Aug 17, 2019
30aa64e
Merge branch 'dev' of github.com:teamnewpipe/newpipe into dev
theScrabi Aug 17, 2019
ac79719
Translated using Weblate (English)
comradekingu Aug 17, 2019
ae0ee61
Translated using Weblate (English)
westminboy Aug 18, 2019
9074733
Translated using Weblate (Thai)
kowith337 Aug 15, 2019
20208be
Translated using Weblate (German)
Aug 15, 2019
e621dd3
Translated using Weblate (English)
westminboy Aug 18, 2019
bc10717
Translated using Weblate (Basque)
osoitz Aug 16, 2019
c8e23fb
Translated using Weblate (Ukrainian)
Aug 16, 2019
0b0f791
Translated using Weblate (Catalan)
marcriera Aug 16, 2019
1187884
Translated using Weblate (Punjabi)
Aug 17, 2019
1bb58a1
Translated using Weblate (Vietnamese)
creeperpatty Aug 17, 2019
645e16f
Translated using Weblate (Arabic)
Aug 16, 2019
7ff48a6
Translated using Weblate (Indonesian)
zmni Aug 15, 2019
9c9dd6c
Translated using Weblate (French)
Floflr Aug 15, 2019
1d6c722
Translated using Weblate (Chinese (Simplified))
westminboy Aug 18, 2019
223ddaa
Translated using Weblate (Norwegian Bokmål)
comradekingu Aug 17, 2019
60f534d
Merge remote-tracking branch 'Weblate/dev' into dev
TobiGr Aug 18, 2019
e4d0635
Translated using Weblate (Portuguese (Brazil))
edcaron Aug 18, 2019
dd276aa
Translated using Weblate (English)
yarons Aug 18, 2019
9d573e1
Translated using Weblate (Japanese)
naofum Aug 18, 2019
e5207f8
Translated using Weblate (Portuguese)
SantosSi Aug 18, 2019
96802c7
Translated using Weblate (Hebrew)
yarons Aug 18, 2019
85632b2
Translated using Weblate (Chinese (Simplified))
westminboy Aug 18, 2019
8885b45
Translated using Weblate (Chinese (Simplified))
Aug 18, 2019
5470c9a
Merge branch 'origin/dev' into Weblate.
weblate Aug 19, 2019
5854675
Merge remote-tracking branch 'Weblate/dev' into dev
TobiGr Aug 21, 2019
c4f08d5
Add changelog for 0.17.1 (760)
TobiGr Aug 18, 2019
e6bcb46
Fix Portuguese minimize_on_exit_summary
TobiGr Aug 18, 2019
acea267
Fix another %s in translation
TobiGr Aug 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
liberapay: TeamNewPipe
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "org.schabi.newpipe"
minSdkVersion 19
targetSdkVersion 28
versionCode 750
versionName "0.17.0"
versionCode 760
versionName "0.17.1"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -57,7 +57,7 @@ dependencies {
exclude module: 'support-annotations'
})

implementation 'com.github.TeamNewPipe:NewPipeExtractor:5f65788a2f89e'
implementation 'com.github.teamnewpipe:NewPipeExtractor:430da57350c587828'

testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.23.0'
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/org/schabi/newpipe/Downloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private ResponseBody getBody(String siteUrl, Map<String, String> customPropertie
final ResponseBody body = response.body();

if (response.code() == 429) {
throw new ReCaptchaException("reCaptcha Challenge requested");
throw new ReCaptchaException("reCaptcha Challenge requested", siteUrl);
}

if (body == null) {
Expand Down Expand Up @@ -214,7 +214,7 @@ public DownloadResponse get(String siteUrl, DownloadRequest request) throws IOEx
final ResponseBody body = response.body();

if (response.code() == 429) {
throw new ReCaptchaException("reCaptcha Challenge requested");
throw new ReCaptchaException("reCaptcha Challenge requested", siteUrl);
}

if (body == null) {
Expand Down Expand Up @@ -268,7 +268,7 @@ public DownloadResponse post(String siteUrl, DownloadRequest request) throws IOE
final ResponseBody body = response.body();

if (response.code() == 429) {
throw new ReCaptchaException("reCaptcha Challenge requested");
throw new ReCaptchaException("reCaptcha Challenge requested", siteUrl);
}

if (body == null) {
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/org/schabi/newpipe/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.schabi.newpipe.util.Constants;
import org.schabi.newpipe.util.KioskTranslator;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.PermissionHelper;
import org.schabi.newpipe.util.ServiceHelper;
import org.schabi.newpipe.util.StateSaver;
import org.schabi.newpipe.util.ThemeHelper;
Expand Down Expand Up @@ -421,6 +422,17 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
return;
}
}
switch (requestCode) {
case PermissionHelper.DOWNLOADS_REQUEST_CODE:
NavigationHelper.openDownloads(this);
break;
case PermissionHelper.DOWNLOAD_DIALOG_REQUEST_CODE:
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_holder);
if (fragment instanceof VideoDetailFragment) {
((VideoDetailFragment) fragment).openDownloadDialog();
}
break;
}
}

/**
Expand Down
16 changes: 11 additions & 5 deletions app/src/main/java/org/schabi/newpipe/ReCaptchaActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,24 @@
*/
public class ReCaptchaActivity extends AppCompatActivity {
public static final int RECAPTCHA_REQUEST = 10;
public static final String RECAPTCHA_URL_EXTRA = "recaptcha_url_extra";

public static final String TAG = ReCaptchaActivity.class.toString();
public static final String YT_URL = "https://www.youtube.com";

private String url;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recaptcha);

url = getIntent().getStringExtra(RECAPTCHA_URL_EXTRA);
if (url == null || url.isEmpty()) {
url = YT_URL;
}


// Set return to Cancel by default
setResult(RESULT_CANCELED);

Expand Down Expand Up @@ -73,15 +82,12 @@ protected void onCreate(Bundle savedInstanceState) {
myWebView.clearHistory();
android.webkit.CookieManager cookieManager = CookieManager.getInstance();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cookieManager.removeAllCookies(new ValueCallback<Boolean>() {
@Override
public void onReceiveValue(Boolean aBoolean) {}
});
cookieManager.removeAllCookies(aBoolean -> {});
} else {
cookieManager.removeAllCookie();
}

myWebView.loadUrl(YT_URL);
myWebView.loadUrl(url);
}

private class ReCaptchaWebViewClient extends WebViewClient {
Expand Down
36 changes: 23 additions & 13 deletions app/src/main/java/org/schabi/newpipe/RouterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@
*/
public class RouterActivity extends AppCompatActivity {

@State protected int currentServiceId = -1;
@State
protected int currentServiceId = -1;
private StreamingService currentService;
@State protected LinkType currentLinkType;
@State protected int selectedRadioPosition = -1;
@State
protected LinkType currentLinkType;
@State
protected int selectedRadioPosition = -1;
protected int selectedPreviously = -1;

protected String currentUrl;
Expand Down Expand Up @@ -257,7 +260,7 @@ private void showDialog(final List<AdapterChoiceItem> choices) {
.setNegativeButton(R.string.just_once, dialogButtonsClickListener)
.setPositiveButton(R.string.always, dialogButtonsClickListener)
.setOnDismissListener((dialog) -> {
if(!selectionIsDownload) finish();
if (!selectionIsDownload) finish();
})
.create();

Expand Down Expand Up @@ -358,13 +361,13 @@ private void setDialogButtonsState(AlertDialog dialog, boolean state) {
positiveButton.setEnabled(state);
}

private void handleText(){
private void handleText() {
String searchString = getIntent().getStringExtra(Intent.EXTRA_TEXT);
int serviceId = getIntent().getIntExtra(Constants.KEY_SERVICE_ID, 0);
Intent intent = new Intent(getThemeWrapperContext(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
NavigationHelper.openSearch(getThemeWrapperContext(),serviceId,searchString);
NavigationHelper.openSearch(getThemeWrapperContext(), serviceId, searchString);
}

private void handleChoice(final String selectedChoiceKey) {
Expand All @@ -382,8 +385,10 @@ private void handleChoice(final String selectedChoiceKey) {
}

if (selectedChoiceKey.equals(getString(R.string.download_key))) {
selectionIsDownload = true;
openDownloadDialog();
if (PermissionHelper.checkStoragePermissions(this, PermissionHelper.DOWNLOAD_DIALOG_REQUEST_CODE)) {
selectionIsDownload = true;
openDownloadDialog();
}
return;
}

Expand All @@ -395,7 +400,7 @@ private void handleChoice(final String selectedChoiceKey) {
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(intent -> {
if(!internalRoute){
if (!internalRoute) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
}
Expand Down Expand Up @@ -445,17 +450,21 @@ private void openDownloadDialog() {

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
for (int i: grantResults){
if (i == PackageManager.PERMISSION_DENIED){
for (int i : grantResults) {
if (i == PackageManager.PERMISSION_DENIED) {
finish();
return;
}
}
if (requestCode == PermissionHelper.DOWNLOAD_DIALOG_REQUEST_CODE) {
openDownloadDialog();
}
}

private static class AdapterChoiceItem {
final String description, key;
@DrawableRes final int icon;
@DrawableRes
final int icon;

AdapterChoiceItem(String key, String description, int icon) {
this.description = description;
Expand Down Expand Up @@ -553,7 +562,8 @@ public Consumer<Info> getResultHandler(Choice choice) {

final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean isExtVideoEnabled = preferences.getBoolean(getString(R.string.use_external_video_player_key), false);
boolean isExtAudioEnabled = preferences.getBoolean(getString(R.string.use_external_audio_player_key), false);;
boolean isExtAudioEnabled = preferences.getBoolean(getString(R.string.use_external_audio_player_key), false);
;

PlayQueue playQueue;
String playerChoice = choice.playerChoice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private void updateFragments() {
.commit();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
Expand All @@ -86,9 +87,4 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
}

@Override
public void onRestoreInstanceState(Bundle inState){
super.onRestoreInstanceState(inState);
}
}
48 changes: 43 additions & 5 deletions app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.annotation.IdRes;
Expand All @@ -33,6 +34,8 @@
import android.widget.TextView;
import android.widget.Toast;

import com.nononsenseapps.filepicker.Utils;

import org.schabi.newpipe.MainActivity;
import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.MediaFormat;
Expand All @@ -45,13 +48,17 @@
import org.schabi.newpipe.extractor.utils.Localization;
import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.report.UserAction;
import org.schabi.newpipe.settings.NewPipeSettings;
import org.schabi.newpipe.util.FilePickerActivityHelper;
import org.schabi.newpipe.util.FilenameUtils;
import org.schabi.newpipe.util.ListHelper;
import org.schabi.newpipe.util.PermissionHelper;
import org.schabi.newpipe.util.SecondaryStreamHelper;
import org.schabi.newpipe.util.StreamItemAdapter;
import org.schabi.newpipe.util.StreamItemAdapter.StreamSizeWrapper;
import org.schabi.newpipe.util.ThemeHelper;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -72,7 +79,7 @@
public class DownloadDialog extends DialogFragment implements RadioGroup.OnCheckedChangeListener, AdapterView.OnItemSelectedListener {
private static final String TAG = "DialogFragment";
private static final boolean DEBUG = MainActivity.DEBUG;
private static final int REQUEST_DOWNLOAD_PATH_SAF = 0x1230;
private static final int REQUEST_DOWNLOAD_SAVE_AS = 0x1230;

@State
protected StreamInfo currentInfo;
Expand Down Expand Up @@ -173,6 +180,11 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
if (DEBUG)
Log.d(TAG, "onCreate() called with: savedInstanceState = [" + savedInstanceState + "]");

if (!PermissionHelper.checkStoragePermissions(getActivity(), PermissionHelper.DOWNLOAD_DIALOG_REQUEST_CODE)) {
getDialog().dismiss();
return;
}

context = getContext();

setStyle(STYLE_NO_TITLE, ThemeHelper.getDialogTheme(context));
Expand Down Expand Up @@ -311,12 +323,18 @@ public void onSaveInstanceState(@NonNull Bundle outState) {
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (requestCode == REQUEST_DOWNLOAD_PATH_SAF && resultCode == Activity.RESULT_OK) {
if (requestCode == REQUEST_DOWNLOAD_SAVE_AS && resultCode == Activity.RESULT_OK) {
if (data.getData() == null) {
showFailedDialog(R.string.general_error);
return;
}

if (FilePickerActivityHelper.isOwnFileUri(context, data.getData())) {
File file = Utils.getFileForUri(data.getData());
checkSelectedDownload(null, Uri.fromFile(file), file.getName(), StoredFileHelper.DEFAULT_MIME);
return;
}

DocumentFile docFile = DocumentFile.fromSingleUri(context, data.getData());
if (docFile == null) {
showFailedDialog(R.string.general_error);
Expand Down Expand Up @@ -569,12 +587,27 @@ private void prepareSelectedDownload() {
// This part is called if with SAF preferred:
// * older android version running
// * save path not defined (via download settings)
// * the user as checked the "ask where to download" option
// * the user checked the "ask where to download" option

if (!askForSavePath)
Toast.makeText(context, getString(R.string.no_available_dir), Toast.LENGTH_LONG).show();

StoredFileHelper.requestSafWithFileCreation(this, REQUEST_DOWNLOAD_PATH_SAF, filename, mime);
if (NewPipeSettings.useStorageAccessFramework(context)) {
StoredFileHelper.requestSafWithFileCreation(this, REQUEST_DOWNLOAD_SAVE_AS, filename, mime);
} else {
File initialSavePath;
if (radioStreamsGroup.getCheckedRadioButtonId() == R.id.audio_button)
initialSavePath = NewPipeSettings.getDir(Environment.DIRECTORY_MUSIC);
else
initialSavePath = NewPipeSettings.getDir(Environment.DIRECTORY_MOVIES);

initialSavePath = new File(initialSavePath, filename);
startActivityForResult(
FilePickerActivityHelper.chooseFileToSave(context, initialSavePath.getAbsolutePath()),
REQUEST_DOWNLOAD_SAVE_AS
);
}

return;
}

Expand Down Expand Up @@ -624,6 +657,11 @@ private void checkSelectedDownload(StoredDirectoryHelper mainStorage, Uri target
// This part is called if:
// * using SAF on older android version
// * save path not defined
// * if the file exists overwrite it, is not necessary ask
if (!storage.existsAsFile() && !storage.create()) {
showFailedDialog(R.string.error_file_creation);
return;
}
continueSelectedDownload(storage);
return;
} else if (targetFile == null) {
Expand Down Expand Up @@ -728,7 +766,7 @@ private void continueSelectedDownload(@NonNull StoredFileHelper storage) {
try {
if (storage.length() > 0) storage.truncate();
} catch (IOException e) {
Log.e(TAG, "failed to overwrite the file: " + storage.getUri().toString(), e);
Log.e(TAG, "failed to truncate the file: " + storage.getUri().toString(), e);
showFailedDialog(R.string.overwrite_failed);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected boolean onError(Throwable exception) {
}

if (exception instanceof ReCaptchaException) {
onReCaptchaException();
onReCaptchaException((ReCaptchaException) exception);
return true;
} else if (exception instanceof IOException) {
showError(getString(R.string.network_error), true);
Expand All @@ -190,11 +190,13 @@ protected boolean onError(Throwable exception) {
return false;
}

public void onReCaptchaException() {
public void onReCaptchaException(ReCaptchaException exception) {
if (DEBUG) Log.d(TAG, "onReCaptchaException() called");
Toast.makeText(activity, R.string.recaptcha_request_toast, Toast.LENGTH_LONG).show();
// Starting ReCaptcha Challenge Activity
startActivityForResult(new Intent(activity, ReCaptchaActivity.class), ReCaptchaActivity.RECAPTCHA_REQUEST);
Intent intent = new Intent(activity, ReCaptchaActivity.class);
intent.putExtra(ReCaptchaActivity.RECAPTCHA_URL_EXTRA, exception.getUrl());
startActivityForResult(intent, ReCaptchaActivity.RECAPTCHA_REQUEST);

showError(getString(R.string.recaptcha_request_toast), false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,10 @@ public void onClick(View v) {
}
break;
case R.id.detail_controls_download:
this.openDownloadDialog();
if (PermissionHelper.checkStoragePermissions(activity,
PermissionHelper.DOWNLOAD_DIALOG_REQUEST_CODE)) {
this.openDownloadDialog();
}
break;
case R.id.detail_uploader_root_layout:
if (TextUtils.isEmpty(currentInfo.getUploaderUrl())) {
Expand Down
Loading