mirror of
https://github.com/k0shk0sh/FastHub.git
synced 2025-12-08 19:05:54 +00:00
fix download releases and release 4.7.2
This commit is contained in:
parent
0b0f15f291
commit
fdec9c1eac
@ -29,8 +29,8 @@ android {
|
||||
applicationId "com.fastaccess.github"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 29
|
||||
versionCode 471
|
||||
versionName "4.7.0"
|
||||
versionCode 472
|
||||
versionName "4.7.2"
|
||||
buildConfigString "GITHUB_CLIENT_ID", (buildProperties.secrets['github_client_id'] | buildProperties.notThere['github_client_id']).string
|
||||
buildConfigString "GITHUB_SECRET", (buildProperties.secrets['github_secret'] | buildProperties.notThere['github_secret']).string
|
||||
buildConfigString "IMGUR_CLIENT_ID", (buildProperties.secrets['imgur_client_id'] | buildProperties.notThere['imgur_client_id']).string
|
||||
|
||||
@ -316,6 +316,10 @@
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<meta-data
|
||||
android:name="io.fabric.ApiKey"
|
||||
android:value="6ed82b6e0756853d7d782a3f547f84f9ecba217e" />
|
||||
|
||||
<meta-data
|
||||
android:name="com.google.firebase.messaging.default_notification_icon"
|
||||
android:resource="@drawable/ic_notification" />
|
||||
|
||||
@ -16,12 +16,19 @@ public class SimpleUrlsModel implements Parcelable {
|
||||
|
||||
public String item;
|
||||
public String url;
|
||||
public String extension;
|
||||
|
||||
public SimpleUrlsModel(String item, String url) {
|
||||
this.item = item;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public SimpleUrlsModel(String item, String url, String extension) {
|
||||
this.item = item;
|
||||
this.url = url;
|
||||
this.extension = extension;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return item;
|
||||
}
|
||||
|
||||
@ -92,6 +92,10 @@ public class RestProvider {
|
||||
}
|
||||
|
||||
public static void downloadFile(@NonNull Context context, @NonNull String url) {
|
||||
downloadFile(context, url, null);
|
||||
}
|
||||
|
||||
public static void downloadFile(@NonNull Context context, @NonNull String url, @Nullable String extension) {
|
||||
try {
|
||||
if (InputHelper.isEmpty(url)) return;
|
||||
boolean isEnterprise = LinkParserHelper.isEnterprise(url);
|
||||
@ -103,6 +107,9 @@ public class RestProvider {
|
||||
request.addRequestHeader("Authorization", authToken.startsWith("Basic") ? authToken : "token " + authToken);
|
||||
}
|
||||
String fileName = new File(url).getName();
|
||||
if (!InputHelper.isEmpty(extension)) {
|
||||
fileName += extension;
|
||||
}
|
||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
|
||||
request.setTitle(fileName);
|
||||
request.setDescription(context.getString(R.string.downloading_file));
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
package com.fastaccess.ui.modules.repos.code.releases;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.annimon.stream.Collectors;
|
||||
@ -139,13 +142,11 @@ public class RepoReleasesFragment extends BaseFragment<RepoReleasesMvp.View, Rep
|
||||
ArrayList<SimpleUrlsModel> models = new ArrayList<>();
|
||||
if (!InputHelper.isEmpty(item.getZipBallUrl())) {
|
||||
String url = item.getZipBallUrl();
|
||||
if (!url.endsWith(".tar.gz")) {
|
||||
url = url + ".tar.gz";
|
||||
}
|
||||
models.add(new SimpleUrlsModel(getString(R.string.download_as_zip), url));
|
||||
models.add(new SimpleUrlsModel(getString(R.string.download_as_zip), url, ".zip"));
|
||||
}
|
||||
if (!InputHelper.isEmpty(item.getTarballUrl())) {
|
||||
models.add(new SimpleUrlsModel(getString(R.string.download_as_tar), item.getTarballUrl()));
|
||||
String url = item.getTarballUrl();
|
||||
models.add(new SimpleUrlsModel(getString(R.string.download_as_tar), url, ".tar.gz"));
|
||||
}
|
||||
if (item.getAssets() != null && !item.getAssets().isEmpty()) {
|
||||
ArrayList<SimpleUrlsModel> mapped = Stream.of(item.getAssets())
|
||||
@ -180,8 +181,10 @@ public class RepoReleasesFragment extends BaseFragment<RepoReleasesMvp.View, Rep
|
||||
}
|
||||
|
||||
@Override public void onItemSelected(SimpleUrlsModel item) {
|
||||
if (ActivityHelper.checkAndRequestReadWritePermission(getActivity())) {
|
||||
RestProvider.downloadFile(getContext(), item.getUrl());
|
||||
Activity activity = getActivity();
|
||||
if (activity == null) return;
|
||||
if (ActivityHelper.checkAndRequestReadWritePermission(activity)) {
|
||||
RestProvider.downloadFile(activity, item.getUrl(), item.extension);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user