Skip to content
This repository was archived by the owner on Sep 30, 2021. It is now read-only.

Commit fdec9c1

Browse files
author
k0shk0sh
committed
fix download releases and release 4.7.2
1 parent 0b0f15f commit fdec9c1

5 files changed

Lines changed: 30 additions & 9 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ android {
2929
applicationId "com.fastaccess.github"
3030
minSdkVersion 21
3131
targetSdkVersion 29
32-
versionCode 471
33-
versionName "4.7.0"
32+
versionCode 472
33+
versionName "4.7.2"
3434
buildConfigString "GITHUB_CLIENT_ID", (buildProperties.secrets['github_client_id'] | buildProperties.notThere['github_client_id']).string
3535
buildConfigString "GITHUB_SECRET", (buildProperties.secrets['github_secret'] | buildProperties.notThere['github_secret']).string
3636
buildConfigString "IMGUR_CLIENT_ID", (buildProperties.secrets['imgur_client_id'] | buildProperties.notThere['imgur_client_id']).string

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@
316316
</intent-filter>
317317
</service>
318318

319+
<meta-data
320+
android:name="io.fabric.ApiKey"
321+
android:value="6ed82b6e0756853d7d782a3f547f84f9ecba217e" />
322+
319323
<meta-data
320324
android:name="com.google.firebase.messaging.default_notification_icon"
321325
android:resource="@drawable/ic_notification" />

app/src/main/java/com/fastaccess/data/dao/SimpleUrlsModel.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,19 @@ public class SimpleUrlsModel implements Parcelable {
1616

1717
public String item;
1818
public String url;
19+
public String extension;
1920

2021
public SimpleUrlsModel(String item, String url) {
2122
this.item = item;
2223
this.url = url;
2324
}
2425

26+
public SimpleUrlsModel(String item, String url, String extension) {
27+
this.item = item;
28+
this.url = url;
29+
this.extension = extension;
30+
}
31+
2532
@Override public String toString() {
2633
return item;
2734
}

app/src/main/java/com/fastaccess/provider/rest/RestProvider.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ private static Retrofit provideRetrofit(boolean enterprise) {
9292
}
9393

9494
public static void downloadFile(@NonNull Context context, @NonNull String url) {
95+
downloadFile(context, url, null);
96+
}
97+
98+
public static void downloadFile(@NonNull Context context, @NonNull String url, @Nullable String extension) {
9599
try {
96100
if (InputHelper.isEmpty(url)) return;
97101
boolean isEnterprise = LinkParserHelper.isEnterprise(url);
@@ -103,6 +107,9 @@ public static void downloadFile(@NonNull Context context, @NonNull String url) {
103107
request.addRequestHeader("Authorization", authToken.startsWith("Basic") ? authToken : "token " + authToken);
104108
}
105109
String fileName = new File(url).getName();
110+
if (!InputHelper.isEmpty(extension)) {
111+
fileName += extension;
112+
}
106113
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, fileName);
107114
request.setTitle(fileName);
108115
request.setDescription(context.getString(R.string.downloading_file));

app/src/main/java/com/fastaccess/ui/modules/repos/code/releases/RepoReleasesFragment.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.fastaccess.ui.modules.repos.code.releases;
22

3+
import android.app.Activity;
34
import android.os.Bundle;
5+
46
import androidx.annotation.NonNull;
57
import androidx.annotation.Nullable;
68
import androidx.annotation.StringRes;
79
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
10+
811
import android.view.View;
912

1013
import com.annimon.stream.Collectors;
@@ -139,13 +142,11 @@ public static RepoReleasesFragment newInstance(@NonNull String repoId, @NonNull
139142
ArrayList<SimpleUrlsModel> models = new ArrayList<>();
140143
if (!InputHelper.isEmpty(item.getZipBallUrl())) {
141144
String url = item.getZipBallUrl();
142-
if (!url.endsWith(".tar.gz")) {
143-
url = url + ".tar.gz";
144-
}
145-
models.add(new SimpleUrlsModel(getString(R.string.download_as_zip), url));
145+
models.add(new SimpleUrlsModel(getString(R.string.download_as_zip), url, ".zip"));
146146
}
147147
if (!InputHelper.isEmpty(item.getTarballUrl())) {
148-
models.add(new SimpleUrlsModel(getString(R.string.download_as_tar), item.getTarballUrl()));
148+
String url = item.getTarballUrl();
149+
models.add(new SimpleUrlsModel(getString(R.string.download_as_tar), url, ".tar.gz"));
149150
}
150151
if (item.getAssets() != null && !item.getAssets().isEmpty()) {
151152
ArrayList<SimpleUrlsModel> mapped = Stream.of(item.getAssets())
@@ -180,8 +181,10 @@ public static RepoReleasesFragment newInstance(@NonNull String repoId, @NonNull
180181
}
181182

182183
@Override public void onItemSelected(SimpleUrlsModel item) {
183-
if (ActivityHelper.checkAndRequestReadWritePermission(getActivity())) {
184-
RestProvider.downloadFile(getContext(), item.getUrl());
184+
Activity activity = getActivity();
185+
if (activity == null) return;
186+
if (ActivityHelper.checkAndRequestReadWritePermission(activity)) {
187+
RestProvider.downloadFile(activity, item.getUrl(), item.extension);
185188
}
186189
}
187190

0 commit comments

Comments
 (0)