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

Commit

Permalink
fix download releases and release 4.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
k0shk0sh committed Dec 28, 2019
1 parent 0b0f15f commit fdec9c1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ private static Retrofit provideRetrofit(boolean enterprise) {
}

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);
Expand All @@ -103,6 +107,9 @@ public static void downloadFile(@NonNull Context context, @NonNull String url) {
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));
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -139,13 +142,11 @@ public static RepoReleasesFragment newInstance(@NonNull String repoId, @NonNull
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())
Expand Down Expand Up @@ -180,8 +181,10 @@ public static RepoReleasesFragment newInstance(@NonNull String repoId, @NonNull
}

@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);
}
}

Expand Down

0 comments on commit fdec9c1

Please sign in to comment.